CI probe (control): #1246's UDP fix reverted - #2
Closed
graingert-coef wants to merge 9 commits into
Closed
Conversation
for more information, see https://pre-commit.ci
Extends the TCP regression test from agronholm#1277 to UDPSocket, ConnectedUDPSocket and Process. The plain variants pass on master too, so they are guards rather than regression tests. The pending-send variants target Windows specifically: _ProactorDatagramTransport.sendto() always buffers and starts an overlapped operation, so transport.close() declines to schedule connection_lost while _write_fut is pending, deferring it to an IOCP completion on a later loop iteration. That should expose UDPSocket.aclose()'s unshielded wait on closed_event, which is invisible on selector loops. Pushed to run the Windows CI matrix; not intended for upstream as-is. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # src/anyio/_backends/_asyncio.py
The previous versions queued sends and then entered a task group, but start_soon() only schedules — the children first run when the host yields at __aexit__, and one event loop iteration is all the proactor needs to reap the overlapped send. close() then took the no-pending-write path and the tests passed on Windows for the wrong reason. anyio puts send()'s checkpoint before transport.sendto(), so the operation is only still in flight if nothing yields afterwards. Drop the pointless 10x send loop (each iteration yielded, so the buffer drained every time) and close directly after a single send, as PR agronholm#1246's own reproducer does. Adds a concurrent variant gated on an Event so the second closer only runs once the first has yielded inside aclose(), which is where its unshielded wait on closed_event is exposed. Neither PR covers that caller. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Control for the pending-send tests: with abort() and the shielded checkpoint removed from UDPSocket.aclose() and ConnectedUDPSocket.aclose(), the wait on closed_event is unshielded again and transport.close() is the only thing scheduling connection_lost. Expected to time out on Windows. Not for merge. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Owner
Author
|
Control run complete — result recorded. With agronholm#1246's UDP
Both modes are the same defect; the call path decides which one you see. Under Closing — superseded by #1. |
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.
Not for merge — control run for #1.
Identical to #1 except
UDPSocket.aclose()/ConnectedUDPSocket.aclose()have PR 1246'sabort()+ shielded checkpoint removed, so the wait onclosed_eventis unshielded again.Prediction
test_aclose_forcefully_with_pending_send(both UDP classes) times out on windows-latest, and passes everywhere else.Mechanism:
_ProactorDatagramTransport.sendto()starts an overlapped op, soclose()skips schedulingconnection_lostwhile_write_futis pending (proactor_events.py:108).close()also increments_conn_lost, so when the completion lands_loop_writing()returns atif self._conn_lost: return(:513) before reaching theif self._closing: call_soon(_call_connection_lost)at:524.connection_lostis therefore never called,closed_eventis never set, and the wait blocks forever. agronholm#1246'sabort()fixes it by routing through_force_close, where thecall_soonis unconditional (:152).My earlier version of these tests passed on Windows for the wrong reason: it entered a task group between the send and the close, and that one event loop iteration was enough for the proactor to reap the overlapped send.
If this run passes on Windows, the mechanism above is wrong and agronholm#1246 fixes something else.