summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-01-18 01:00:46 (GMT)
committerNed Deily <nad@python.org>2019-01-18 01:00:46 (GMT)
commit7eef540ab89e426b622373f43713521876447f2f (patch)
tree2a28d728ad2dc4bac39e18ef5b50ce7f4b4003ed
parent216a4d83c3b72f4fdcd81b588dc3f42cc461739a (diff)
downloadcpython-7eef540ab89e426b622373f43713521876447f2f.zip
cpython-7eef540ab89e426b622373f43713521876447f2f.tar.gz
cpython-7eef540ab89e426b622373f43713521876447f2f.tar.bz2
bpo-35601: Alleviate race condition when waiting for SIGALRM in test_asyncio (GH-11337) (GH-11348)
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@gmail.com>
-rw-r--r--Lib/test/test_asyncio/test_events.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 91d8a96..b62c0f3 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -557,6 +557,7 @@ class EventLoopTestsMixin:
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)
@@ -569,11 +570,12 @@ class EventLoopTestsMixin:
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)