Make QRTConnection an async context manager, close Discover transport#59
Open
ulvs wants to merge 1 commit into
Open
Make QRTConnection an async context manager, close Discover transport#59ulvs wants to merge 1 commit into
ulvs wants to merge 1 commit into
Conversation
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>
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.
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).Discovertracks its UDP datagram transport and closes it onStopAsyncIteration, so iterating to the end no longer leaks the socket.qtm-rt-examples.zipasset, Ruff in CI, FIFOrequest_queueper 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
ResourceWarningwhen wrapped inasync with connection:. Updating the examples themselves is a small follow-up.