Repository navigation
ci: lint async code for blocking calls and unreferenced tasks - #848
Merged
Merged
Conversation
Turn on ruff's ASYNC rules and RUF006 next to pyflakes. The DNS resolver in site_proxy.py now keeps a reference to each answer task.
andrewpark-scaleai
enabled auto-merge (squash)
November 20, 2026 22:54
earakely-scale
approved these changes
Nov 22, 2026
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.
Why
ruff checkruns only pyflakes today. Nothing stops a blocking call, liketime.sleep,subprocess.runor a sync HTTP request, from landing in an async function and stalling the event loop for every run it serves. This PR adds the async checks that catch those mistakes, and changes the one line insrc/they flag.What changes
pyproject.tomlselects ruff'sASYNCrules andRUF006(a task with no reference, which the garbage collector may drop before it finishes).ASYNC109objects to atimeoutparameter, which is this codebase's style.ASYNC110flags polling loops. Ours poll processes, files and other threads, which noasyncio.Eventcan signal.ASYNC230andASYNC240flag sync file I/O. Ours is small writes and chunked streams.ASYNC2xx) and fire tasks without keeping them, since several do that on purpose.subprocess.Popen(ASYNC220). Its VM and port relay are detached processes that outlive the call.site_proxy.Resolverkeeps each DNS answer task in a set until it finishes, as theasynciodocs require for fire-and-forget tasks. This doesn't fix an observed failure. While a forwarded query is pending, the loop's selector holds the socket's callback, which keeps the task alive. 200 queries against a nameserver that answers after 0.5 s, withgc.collect()forced every 50 ms, all got answers onmaintoo, while a control that awaits an unreferenced future lost all 200 tasks. The change makes the resolver rely on asyncio's documented contract rather than on that selector detail, and letsRUF006run without an exception.With this config,
src/andpackages/agentenv-protocol/srchave no hits for blocking HTTP,subprocess.run/check_output,time.sleeporinput()in async functions, so these rules guard new code without a backlog.Testing
ruff checkpasses on the whole repo.tst/unit/env/envs/test_computer_site_proxy.pypasses (74 tests). The earlier DNS tests callResolver._answer()directly, so a new test binds the resolver to a UDP socket and sends it 21 queries while a slow stand-in nameserver holds 20 of them open andgc.collect()runs. It fails whendatagram_receiveddrops a query, and passed 5 runs out of 5.time.sleep,subprocess.runand a droppedcreate_taskinside an async function fails the new config withASYNC251,ASYNC221andRUF006. The oldselect = ["F"]config passes it.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
Adds Ruff async checks and keeps DNS answer tasks referenced until they finish.
Reviews (7) · Last reviewed commit: "test(site-proxy): name the UDP test's qu..." · Reviewed by Greptile