]> granicus.if.org Git - python/commitdiff
bpo-34130: Fix test_signal.test_socket() (GH-8326) (GH-8330)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 18 Jul 2018 17:02:06 +0000 (10:02 -0700)
committerVictor Stinner <vstinner@redhat.com>
Wed, 18 Jul 2018 17:02:06 +0000 (19:02 +0200)
test_signal.test_socket(): On Windows, sometimes even if the C signal handler
succeed to write the signal number into the write end of the socketpair, the
test fails with a BlockingIOError on the non-blocking read.recv(1) because the
read end of the socketpair didn't receive the byte yet.

Fix the race condition on Windows by setting the read end as blocking.
(cherry picked from commit 99bb6df66a42625367c4f38e6802c8bb527baf4a)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
Lib/test/test_signal.py

index 8d6386793d4a57cf309f6201c80f92515ea632bc..5565eb745caf12500b8684fe4dd0ee7259200dcb 100644 (file)
@@ -370,7 +370,6 @@ class WakeupSocketSignalTests(unittest.TestCase):
         signal.signal(signum, handler)
 
         read, write = socket.socketpair()
-        read.setblocking(False)
         write.setblocking(False)
         signal.set_wakeup_fd(write.fileno())