Opened 5 years ago

Last modified 4 years ago

#31509 closed New feature

Enable faulthandler automatically during tests — at Version 1

Reported by: Adam Johnson Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Adam Johnson)

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, 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 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.

Change History (1)

comment:1 by Adam Johnson, 5 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top