fix: cancel periodic status check task when process raises ConstraintError#228
Open
fix: cancel periodic status check task when process raises ConstraintError#228
Conversation
When a component's run task is cancelled (e.g. due to ConstraintError from another component), the asyncio.wait() call in _io_read_with_status_check() did not propagate the cancellation to its child tasks. This caused the _periodic_status_check() background task to keep running indefinitely after the process ended, logging 'State backend not connected, skipping status check' every 20 seconds. Fix: catch BaseException in _io_read_with_status_check() and explicitly cancel the status_task (periodic status check) before re-raising. The io_task is intentionally left uncancelled to avoid breaking existing behavior in IOController._read_tasks state management. Also adds an integration test to verify the fix using a short timeout patch. Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
…bility Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix status check running after ConstraintError in process
fix: cancel periodic status check task when process raises ConstraintError
Mar 10, 2026
|
Benchmark comparison for |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
After a process fails (e.g. via
ConstraintError), the_periodic_status_checkbackground task on waiting components was not being cancelled — causing it to log"State backend not connected, skipping status check"every 20s indefinitely after process teardown.Summary
Python's
asyncio.wait()does not propagate cancellation to its child tasks when the outer task is cancelled. WhenLocalProcess.run()'sTaskGroupcancelled component B's task due to component A raisingConstraintError, theCancelledErrorraised in_io_read_with_status_checkleft the_periodic_status_checktask orphaned in the event loop.Changes
plugboard/component/component.py: In_io_read_with_status_check, wrapasyncio.wait()intry/except BaseExceptionand explicitly cancelstatus_taskbefore re-raising.io_taskis intentionally left uncancelled — cancelling it leaves stale entries inIOController._read_tasksthat break subsequent reads.tests/integration/test_process_with_components_run.py: Addedtest_constraint_error_stops_background_status_check— patchesIO_READ_TIMEOUT_SECONDSto 0.1s, runs a process where the producer raisesConstraintError, and asserts the consumer's background status check task count does not increase after the process fails.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.sh/usr/bin/curl curl -LsSf REDACTED(dns block)metadata.google.internal/usr/bin/python3 /usr/bin/python3 /home/REDACTED/.local/lib/python3.12/site-packages/ray/dashboard/dashboard.py --host=127.0.0.1 --port=8265 --port-retries=50 --temp-dir=/tmp/ray --log-dir=/tmp/ray/session_2026-03-10_12-24-30_696966_4740/logs --session-dir=/tmp/ray/session_2026-03-10_12-24-30_696966_4740 --logging-rotate-bytes=536870912 --logging-rotate-backup-count=5 --gcs-address=127.0.0.1:41467 --cluster-id-hex=315478065acf40787bae5a5a2d085e45ba453b1cdf3b6bb9491c8a13 --node-ip-address=127.0.0.1 --stdout-filepath=/tmp/ray/session_2026-03-10_12-24-30_696966_4740/logs/dashboard.out --stderr-filepath=/tmp/ray/session_2026-03-10_12-24-30_696966_4740/logs/dashboard.err de/node/bin/bash(dns block)/usr/bin/python3 /usr/bin/python3 /home/REDACTED/.local/lib/python3.12/site-packages/ray/dashboard/dashboard.py --host=127.0.0.1 --port=8265 --port-retries=50 --temp-dir=/tmp/ray --log-dir=/tmp/ray/session_2026-03-10_12-25-36_456083_5403/logs --session-dir=/tmp/ray/session_2026-03-10_12-25-36_456083_5403 --logging-rotate-bytes=536870912 --logging-rotate-backup-count=5 --gcs-address=127.0.0.1:36975 --cluster-id-hex=d4d2c57ba441af7a721e338a987f2c67a082d7e7dabcda1628e8b01c --node-ip-address=127.0.0.1 --stdout-filepath=/tmp/ray/session_2026-03-10_12-25-36_456083_5403/logs/dashboard.out --stderr-filepath=/tmp/ray/session_2026-03-10_12-25-36_456083_5403/logs/dashboard.err /home/REDACTED/.config/composer/vendor/bin/git(dns block)/usr/bin/python3 /usr/bin/python3 /home/REDACTED/.local/lib/python3.12/site-packages/ray/dashboard/dashboard.py --host=127.0.0.1 --port=8265 --port-retries=50 --temp-dir=/tmp/ray --log-dir=/tmp/ray/session_2026-03-10_12-28-25_364935_6030/logs --session-dir=/tmp/ray/session_2026-03-10_12-28-25_364935_6030 --logging-rotate-bytes=536870912 --logging-rotate-backup-count=5 --gcs-address=127.0.0.1:36649 --cluster-id-hex=0a7c71f1c8306fa045621fa679f13bfe448ffad9bf7a61dfae288243 --node-ip-address=127.0.0.1 --stdout-filepath=/tmp/ray/session_2026-03-10_12-28-25_364935_6030/logs/dashboard.out --stderr-filepath=/tmp/ray/session_2026-03-10_12-28-25_364935_6030/logs/dashboard.err sh credential.usernbash(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.