summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2018-12-29 01:40:21 (GMT)
committerGitHub <noreply@github.com>2018-12-29 01:40:21 (GMT)
commit5471420faa84519530f29b08f2b042b2288e3e96 (patch)
treedfb5854eea44c85f52ed078616927f89554f6340 /Lib
parent4bc246786f003cdf1fffb3403b4cd92fc42ba9ef (diff)
downloadcpython-5471420faa84519530f29b08f2b042b2288e3e96.zip
cpython-5471420faa84519530f29b08f2b042b2288e3e96.tar.gz
cpython-5471420faa84519530f29b08f2b042b2288e3e96.tar.bz2
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.
Diffstat (limited to 'Lib')
-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 9311a20..a2b954e 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -475,6 +475,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)
@@ -487,11 +488,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)