Skip to content

Commit af79f49

Browse files
asvetlovclaude
andauthored
gh-160561: Fix race in test_socket testFromFdError (#160930)
The client thread closes its socket in clientTearDown() concurrently with the server-side test, so the process-wide fd count could drop between the two os_helper.fd_count() calls. Wait for the client thread to finish before taking the first count. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent bd3be61 commit af79f49

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎Lib/test/test_socket.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,6 +3231,9 @@ def _testFromFd(self):
32313231
def testFromFdError(self):
32323232
# Make sure that the fromfd() duplicated socket is closed on error.
32333233
fd = self.cli_conn.fileno()
3234+
# Wait for the client thread to close its socket, otherwise
3235+
# fd_count() can race with clientTearDown().
3236+
self.done.wait()
32343237
fd_count_before = os_helper.fd_count()
32353238

32363239
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)