Conversation
…hat follows. Fixes python#21484 "Failed to write with error: 233" on Windows. This change creates parity between Windows and POSIX. An IPCServer's timeout applies to accepting a connection. On POSIX it stops there, because it is set on the listening socket and accept() hands back a blocking one, but on Windows it applies to the pipe handle and so also bounds every subsequent read and write. Once a peer is connected it may legitimately stay silent for a long time while it computes, so this makes Windows give up on perfectly healthy peers. After a build worker sends its setup ack it blocks in receive() waiting for the graph, but the coordinator only broadcasts the graph once it has finished loading it, which routinely takes longer than WORKER_CONNECTION_TIMEOUT on a large or cold-cache build. The worker's read fails with "Bad result from I/O wait: 258" (WAIT_TIMEOUT), main() swallows it, and the worker exits 0. When the coordinator finally broadcasts, every write thread dies against a pipe with nobody on the other end: Exception in thread Thread-7 (write_bytes): File "mypy/ipc.py", line 158, in write_bytes OSError: [WinError 233] No process is on the other end of the pipe ... mypy.ipc.IPCException: Failed to write with error: 233 and the following wait_ack() reports "Worker 0 disconnected before sending data (exit code 0)". Split the timeout used by reads and writes from the one used to connect, and have IPCServer clear it, which is what POSIX already does. IPCClient keeps applying it to reads and writes, also matching POSIX, where it is set on the connected socket -- "dmypy hang" relies on that.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
ilevkivskyi
approved these changes
Sep 21, 2026
ilevkivskyi
left a comment
Member
There was a problem hiding this comment.
Nice! I just have couple style comments (if you don't have time, I can apply them myself).
| self.name = name | ||
| self.timeout = timeout | ||
| self.timeout = timeout # Connections | ||
| self.io_timeout = timeout # Reads and writes |
Member
There was a problem hiding this comment.
This name is a bit misleading. It looks like it would affect POSIX as well. I think it is better to call this win_io_timeout.
| # connection, never to the traffic that follows: see __enter__ below. Once a | ||
| # peer is connected it may legitimately stay silent for a long time while it | ||
| # computes. | ||
| self.io_timeout = None |
Member
There was a problem hiding this comment.
Two things here: move this under an if on the next line, then delete the comment below and combine it with this one and simplify. For example:
# Unlike the client, a server applies its timeout only to accepting a
# connection, never to the traffic that follows: see __enter__() below.
# On POSIX this happens naturally after the sock.accept() call. On
# Windows we need to set this manually to ensure equivalent behavior.
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.
Fixes #21484 "Failed to write with error: 233" on Windows.
This change creates parity between Windows and POSIX, by not applying a server's connection timeout to the read/write traffic that follows on Windows.
Problem
An
IPCServer's timeout applies to accepting a connection. On POSIX it stops there, because it is set on the listening socket andaccept()hands back a blocking one, but on Windows it applies to the pipe handle and so also bounds every subsequent read and write. Once a peer is connected, the peer may legitimately stay silent for a long time while it computes, so this makes Windows give up on perfectly healthy peers.After a build worker sends its setup ack it blocks in
receive()waiting for the graph, but the coordinator only broadcasts the graph once it has finished loading it, which routinely takes longer thanWORKER_CONNECTION_TIMEOUTon a large or cold-cache build. The worker's read fails with "Bad result from I/O wait: 258" (WAIT_TIMEOUT),main()swallows it, and the worker exits 0. When the coordinator finally broadcasts, every write thread dies looking for a pipe with nobody on the other end:and the following
wait_ack()reports "Worker 0 disconnected before sending data (exit code 0)".Solution
Split the timeout used by reads and writes from the one used to connect, and have IPCServer clear it, which is what POSIX already does.
IPCClientkeeps applying it to reads and writes, also matching POSIX, where it is set on the connected socket -- "dmypy hang" relies on that.