Skip to content

Make QRTConnection an async context manager, close Discover transport#59

Open
ulvs wants to merge 1 commit into
masterfrom
qrt_async_context_manager
Open

Make QRTConnection an async context manager, close Discover transport#59
ulvs wants to merge 1 commit into
masterfrom
qrt_async_context_manager

Conversation

@ulvs

@ulvs ulvs commented Jun 10, 2026

Copy link
Copy Markdown
Member

Closes the asyncio transport-leak ResourceWarnings that surface under Python 3.14. GC-based cleanup no longer fires before the warning; we need deterministic close.

  • QRTConnection.__aenter__/__aexit__async with await qtm_rt.connect(...) as c: closes the TCP transport on scope exit.
  • disconnect() made idempotent (safe to call after the context manager already closed).
  • Discover tracks its UDP datagram transport and closes it on StopAsyncIteration, so iterating to the end no longer leaks the socket.
  • Adds CLAUDE.md (already used on-disk by the team but never checked in), updated for current master: Python 3.10+, Trusted-Publishing release flow with qtm-rt-examples.zip asset, Ruff in CI, FIFO request_queue per Fix RT connection drop when responses race with caller timeouts #48, and the new context-manager surface.

Verified end-to-end against QTM 2026.3 Beta on Python 3.14: all seven examples shut down without ResourceWarning when wrapped in async with connection:. Updating the examples themselves is a small follow-up.

Closes the asyncio transport-leak ResourceWarnings that surface under
Python 3.14 (where the GC-based cleanup path no longer fires before the
warning). QRTConnection now supports `async with`, so the transport is
closed deterministically on scope exit; disconnect() is idempotent so
explicit cleanup remains safe to layer on top.

Discover tracks its UDP datagram transport and closes it on
StopAsyncIteration, so iterating to the end no longer leaks the socket.

Also adds CLAUDE.md (the existing on-disk file used by the team, not yet
checked in), updated to reflect current master: Python 3.10+ floor,
pyproject.toml release flow with Trusted Publishing and
qtm-rt-examples.zip release asset, Ruff linting in CI, FIFO
request_queue (per #48), and the new context-manager surface here.

Verified end-to-end against QTM 2026.3 Beta on Python 3.14: all seven
examples shut down without ResourceWarning when wrapped in
`async with connection:` (example wrapping itself is a follow-up).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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