#31509: Enable faulthandler automatically during tests
-------------------------------------------------+------------------------
               Reporter:  Adam (Chainz) Johnson  |          Owner:  nobody
                   Type:  New feature            |         Status:  new
              Component:  Testing framework      |        Version:  master
               Severity:  Normal                 |       Keywords:
           Triage Stage:  Unreviewed             |      Has patch:  0
    Needs documentation:  0                      |    Needs tests:  0
Patch needs improvement:  0                      |  Easy pickings:  1
                  UI/UX:  0                      |
-------------------------------------------------+------------------------
 Sometimes when testing one discovers a "hang". This can be hard to
 diagnose since default test output just includes dots, so one can't tell
 which test has hung. Also hangs can be random, so hard to diagnose.

 In such cases, [https://docs.python.org/3/library/faulthandler.html
 faulthandler] is useful to enable, as killing the process will output a
 stack trace for each thread.

 Tests can be run using faulthandler with `python -X faulthandler manage.py
 test`. However this needs both knowledge that it exists, and re-running
 the tests, when the hang might be non-deterministic.

 Pytest
 [https://docs.pytest.org/en/latest/usage.html?highlight=faulthandler
 #fault-handler automatically enables faulthandler] and provides the option
 to disable it. I suggest we replicate the same in Django's
 `DiscoverRunner` - call `faulthandler.enable()` at the start of tests,
 unless disabled with a flag `--no-faulthandler`.

 Searching for past issues, it seems we've had three tickets where
 faulthandler was recommended for diagnosis:
 https://code.djangoproject.com/search?q=faulthandler . Additionally there
 are probably other cases where no progress was made on a bug because of
 lack of `faulthandler` knowledge.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31509>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.1ea557d26f54f760031a5639f413e4f9%40djangoproject.com.

Reply via email to