Skip to content

server: require owned timed awaits - #934

Merged
yisding merged 1 commit into
agent/ws25-websocket-close-scopefrom
agent/ws25-safe-await-owned-input
Aug 7, 2026
Merged

server: require owned timed awaits#934
yisding merged 1 commit into
agent/ws25-websocket-close-scopefrom
agent/ws25-safe-await-owned-input

Conversation

@yisding

@yisding yisding commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Problem

_safe_await unconditionally passed every awaitable through asyncio.ensure_future, even when no timeout was requested. That hid a raw task start inside a best-effort reap helper and allowed timed callers to hand it bare, otherwise-unowned cleanup coroutines.

Changes

  • await non-timeout cleanup inline
  • require timed cleanup input to already be a Future or Task
  • cancel owned futures or close never-started coroutines when cancellation is pending at helper entry
  • preserve child-cancellation swallowing and caller-cancellation propagation
  • add a regression test proving timed bare coroutines are rejected and closed
  • reduce the raw production task baseline from 24 to 23
  • document the ownership contract

Why / impact

The helper no longer creates hidden work. Timed cleanup must establish ownership before waiting, while ordinary best-effort cleanup keeps its existing exception and cancellation behavior.

Checks

  • .venv/bin/python -m pytest tests/server/test_capacity_gate_drain.py tests/server/test_websocket_runtime_drain.py -q (81 passed)
  • .venv/bin/python -m pytest tests/ratchets/test_source_inventory.py -q (9 passed)
  • .venv/bin/ruff check src/easycat/server/transports.py tests/server/test_capacity_gate_drain.py
  • .venv/bin/ruff format --check src/easycat/server/transports.py tests/server/test_capacity_gate_drain.py
  • .venv/bin/mypy src/easycat/server/transports.py
  • pre-commit hooks

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 389097da-b2d1-4c13-a9a5-7f243efc5367

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yisding
yisding marked this pull request as ready for review August 7, 2026 02:45
@yisding
yisding force-pushed the agent/ws25-safe-await-owned-input branch from 1cf793a to 6b9902d Compare August 7, 2026 03:15
@yisding
yisding force-pushed the agent/ws25-safe-await-owned-input branch from 6b9902d to 8a189f3 Compare August 7, 2026 03:48
@yisding
yisding merged commit bc36a53 into agent/ws25-voice-server-listener-scope Aug 7, 2026
2 checks passed
@yisding
yisding deleted the agent/ws25-safe-await-owned-input branch August 7, 2026 04:11
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.

1 participant