#31509: Enable faulthandler automatically during tests
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Adam (Chainz) Johnson:
Old description:
> 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.
New description:
Sometimes when testing one discovers a "hang," segfault, or other issue.
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#comment:1>
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/068.f3f7fb248c77b2b85002f62f6c06909a%40djangoproject.com.