You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(support): time_limit's one-shot alarm can be swallowed and hang an xdist worker #1892
tests/_support.time_limit (tests/_support.py:75) arms a single signal.alarm(seconds), and its handler raises TimeoutError exactly once. #1891 found that this one-shot pattern can be lost. A finaliser that runs the raise sends it to sys.unraisablehook, and an except OSError swallows it because TimeoutError is an OSError (Extractor.__del__ catches exactly that). Either way the body then runs until pytest-timeout's 900s backstop ends the xdist worker. That is what hung the #1428 deadline test (#1889).
time_limit has the same exposure: a lost raise turns a bounded test into a 15-minute worker crash with no traceback.
Fix: once it has fired, re-arm until the with block exits, as #1891 does for the generator's _deadline. The re-arm must not outlive the block, and the previous handler and pending alarm must still be restored. Add a test where a finaliser swallows the first raise, and check that it fails quickly without the fix.
Related: under xdist, pytest-timeout writes its stack dump to the worker's stdout, which is /dev/null. A hang like #1889's leaves only node down: Not properly terminated. Consider sending the dump somewhere the job log keeps, for example through faulthandler to stderr or a file the job uploads.
Activity
test(support): re-arm time_limit's alarm so a swallowed timeout canno…
test(support): re-arm time_limit's alarm so a swallowed timeout canno…