Re-arm pytest-timeout's timer for each rerun attempt - #383
LouisDeconinck wants to merge 3 commits into
Conversation
pytest-timeout arms a single timer around pytest_runtest_protocol, so after it fired on the first attempt every rerun ran unbounded. Detect the plugin's whole-protocol timeout and cancel/re-arm the timer at the start of each attempt. timeout_func_only already works per attempt via pytest_runtest_call. Closes pytest-dev#99. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The per-attempt timeout is re-armed before runtestprotocol(), but it is not cancelled when that attempt returns. pytest-timeout only cancels its outer timer after this entire protocol hook finishes, while this plugin can still process reports and sleep for reruns_delay before the next iteration. A quick failure with --timeout 1 --reruns 1 --reruns-delay 2 can therefore time out during the backoff instead of giving the next attempt a fresh timeout. Please cancel the per-attempt timer immediately after runtestprotocol() (including exceptional paths), then re-arm it at the next attempt, and add a delay-greater-than-timeout regression.
The re-armed timer stayed armed while rerun reports were processed and during reruns_delay, so a delay longer than the timeout could kill the run before the next attempt got a fresh timer. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Fixed in ec2934c: the per-attempt timer is now cancelled in a |
|
Fixed — the per-attempt timer is cancelled in a |
Summary
pytest_runtest_protocol; once it fired on the first attempt, every rerun ran without a timeoutfunc_only=False) and cancels/re-armspytest_timeout_cancel_timer/pytest_timeout_set_timerat the start of each attempt, so each attempt gets the full configured timeout (verified: a 5s test with--timeout 1 --reruns 1now fails in ~2s instead of passing in ~6s)timeout_func_onlyalready worked per attempt viapytest_runtest_calland is untouchedCloses #99
Test plan
1 failed, 1 rerun)