Add cooperative signal timeouts - #1548
Open
tamird wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1548 +/- ##
==========================================
+ Coverage 94.50% 95.38% +0.87%
==========================================
Files 2 3 +1
Lines 510 628 +118
Branches 62 78 +16
==========================================
+ Hits 482 599 +117
+ Misses 22 19 -3
- Partials 6 10 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tamird
force-pushed
the
tamird/pytest-timeout-integration
branch
2 times, most recently
from
August 20, 2026 01:07
d36b012 to
c149e1f
Compare
A signal timeout can interrupt asyncio while it schedules a task's next step, leaving the task pending without a continuation [1]. Catching the resulting pytest failure and cancelling that task cannot reliably recover it. Add opt-in cooperative delivery through pytest-timeout's proposed expiry hook [2]. Queue cancellation without raising into the scheduler, then report the supplied failure at the owned runner boundary. Preserve external cancellation, process-control exceptions, and the interrupted await's traceback. Stop final runner shutdown separately when it times out; ordinary shared-runner invocations remain reusable. Keep timer selection, deadlines, debugger handling, and diagnostics in pytest-timeout. Existing signal behavior remains the default. Cooperative cancellation cannot stop blocking or cancellation-resistant code, so the thread method remains the hard process-stop option. Final runner shutdown may leave resource cleanup incomplete. Pin the producer prerequisite in a dedicated integration environment until its hook is released. Collect coverage from the isolated pytest processes and map installed-wheel paths back to the source tree. Require Coverage.py 7.10.3 for its subprocess-directory fixes [3]. [1]: pytest-dev/pytest-timeout#113 [2]: pytest-dev/pytest-timeout#204 [3]: https://coverage.readthedocs.io/en/7.10.3/changes.html
tamird
force-pushed
the
tamird/pytest-timeout-integration
branch
from
August 20, 2026 01:53
c149e1f to
58aed64
Compare
tamird
marked this pull request as ready for review
August 20, 2026 02:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A signal timeout can interrupt asyncio while it schedules a task's next step, leaving a pending task with no continuation 1. Catching the resulting failure and cancelling that task cannot reliably recover it.
Add opt-in cooperative signal timeouts through the proposed pytest-timeout expiry hook 2. The signal handler records the supplied failure and queues cancellation without raising into the scheduler. The owned runner then reports the timeout with the interrupted await's traceback, while preserving process-control exceptions and external cancellation. Final runner shutdown has a separate interruption path that closes the loop and may leave resource cleanup incomplete.
Existing signal behavior remains the default. Cooperative cancellation cannot stop an indefinitely blocking callback or a task that refuses to finish; pytest-timeout's thread method remains the hard process-stop option. This consumer does not take over other async plugins, synchronous tests that call asyncio.run(), retry budgets, or background-task ownership.
This keeps runner integration separate from timer policy, as requested in the earlier timeout discussion 3. The dedicated integration environment pins the producer prerequisite; that pin should become a released test dependency once the hook is available. Related to #215.
Prepared with Codex assistance.