Skip to content

utils: Use asyncio.gather with fail-fast behaviour#511

Open
bbhtt wants to merge 1 commit intomasterfrom
bbhtt/failfast
Open

utils: Use asyncio.gather with fail-fast behaviour#511
bbhtt wants to merge 1 commit intomasterfrom
bbhtt/failfast

Conversation

@bbhtt
Copy link
Copy Markdown
Contributor

@bbhtt bbhtt commented Apr 23, 2026

asyncio.gather does not cancel sibling tasks when one fails, so if one
checker raises an unhandled exception, other tasks running I/O may keep
the event loop alive indefinitely. So use asyncio_gather_failfast to
detect failures and explicitly cancel+drain all pending tasks before
re-raising the exception.

In Python 3.11+ this is offered by TaskGroup but it is cheap to
use a wrapper here.

See python/cpython#75633

Fixes: #420

@bbhtt bbhtt force-pushed the bbhtt/failfast branch 2 times, most recently from 57ec589 to 50eee74 Compare April 23, 2026 07:13
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 23, 2026

Coverage Status

coverage: 90.747% (-0.04%) from 90.785% — bbhtt/failfast into master

asyncio.gather does not cancel sibling tasks when one fails, so if one
checker raises an unhandled exception, other tasks running I/O may keep
the event loop alive indefinitely. So use asyncio_gather_failfast to
detect failures and explicitly cancel+drain all pending tasks before
re-raising the exception.

In Python 3.11+ this is offered by TaskGroup but it is cheap to
use a wrapper here.

See python/cpython#75633

Fixes: #420
@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 23, 2026

This seems correct to me but I didn't manage to reproduce the hang with 1a0e0c7 reverted and a broken manifest locally. I think it requires some running / semi-stuck network I/O and I can't get that. So it's a bit theoretical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hangs (sometimes) if a checker raises an assertion failure

2 participants