[Python-checkins] bpo-35601: Alleviate race condition when waiting for SIGALRM in test_asyncio (GH-11337)

Miss Islington (bot) webhook-mailer at python.org
Fri Dec 28 21:01:03 EST 2018


https://github.com/python/cpython/commit/8f9228dd3a37c98876c9c8ff7fb0042650303474
commit: 8f9228dd3a37c98876c9c8ff7fb0042650303474
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-12-28T18:01:00-08:00
summary:

bpo-35601: Alleviate race condition when waiting for SIGALRM in test_asyncio (GH-11337)


There is a race condition regarding signal delivery in test_signal_handling_args for
test_asyncio.test_events.KqueueEventLoopTests. The signal can be received at any moment outside the time window provided in the test. The fix is to wait for the signal to be received instead with a bigger timeout.
(cherry picked from commit 5471420faa84519530f29b08f2b042b2288e3e96)

Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>

files:
M Lib/test/test_asyncio/test_events.py

diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 66b060349007..9466111b8ef7 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -574,6 +574,7 @@ def my_handler():
         self.loop.add_signal_handler(signal.SIGALRM, my_handler)
 
         signal.setitimer(signal.ITIMER_REAL, 0.01, 0)  # Send SIGALRM once.
+        self.loop.call_later(60, self.loop.stop)
         self.loop.run_forever()
         self.assertEqual(caught, 1)
 
@@ -586,11 +587,12 @@ def my_handler(*args):
             nonlocal caught
             caught += 1
             self.assertEqual(args, some_args)
+            self.loop.stop()
 
         self.loop.add_signal_handler(signal.SIGALRM, my_handler, *some_args)
 
         signal.setitimer(signal.ITIMER_REAL, 0.1, 0)  # Send SIGALRM once.
-        self.loop.call_later(0.5, self.loop.stop)
+        self.loop.call_later(60, self.loop.stop)
         self.loop.run_forever()
         self.assertEqual(caught, 1)
 



More information about the Python-checkins mailing list