Skip to content

Commit 1bbe7e9

Browse files
miss-islingtonasvetlovclaude
authored
[3.15] gh-160561: Fix race in test_socket testFromFdError (GH-160930) (#160955)
gh-160561: Fix race in test_socket testFromFdError (GH-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. (cherry picked from commit af79f49) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8fe7cfa commit 1bbe7e9

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
@@ -3178,6 +3178,9 @@ def _testFromFd(self):
31783178
def testFromFdError(self):
31793179
# Make sure that the fromfd() duplicated socket is closed on error.
31803180
fd = self.cli_conn.fileno()
3181+
# Wait for the client thread to close its socket, otherwise
3182+
# fd_count() can race with clientTearDown().
3183+
self.done.wait()
31813184
fd_count_before = os_helper.fd_count()
31823185

31833186
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)