]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-110167: Fix test_socket deadlock in doCleanups() (GH-110416) (#110423)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 5 Oct 2023 19:24:26 +0000 (12:24 -0700)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2023 19:24:26 +0000 (19:24 +0000)
commit2ab41c8fbc6beafebe44f232227cb593cbe7a0bd
tree95ce7d1d535bb02b6d79e40b0881dbcae2b16866
parent5b66fe8304feaf39754e83c21cdfea110e688434
[3.12] gh-110167: Fix test_socket deadlock in doCleanups() (GH-110416) (#110423)

gh-110167: Fix test_socket deadlock in doCleanups() (GH-110416)

Fix a deadlock in test_socket when server fails with a timeout but
the client is still running in its thread. Don't hold a lock to call
cleanup functions in doCleanups(). One of the cleanup function waits
until the client completes, whereas the client could deadlock if it
called addCleanup() in such situation.

doCleanups() is called when the server completed, but the client can
still be running in its thread especially if the server failed with a
timeout. Don't put a lock on doCleanups() to prevent deadlock between
addCleanup() called in the client and doCleanups() waiting for
self.done.wait of ThreadableTest._setUp().
(cherry picked from commit 318f5df27109ff8d2519edefa771920a0ec62b92)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_socket.py
Misc/NEWS.d/next/Tests/2023-10-05-19-33-49.gh-issue-110167.mIdj3v.rst [new file with mode: 0644]