← Back to DAGDA | Support | Source: https://github.com/python/cpython/commit/8f9228dd3a37c98876c9c8ff7fb0042650303474
Skip to content

Commit 8f9228d

Browse files
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 5471420) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent 95dc457 commit 8f9228d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Lib/test/test_asyncio/test_events.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def my_handler():
574574
self.loop.add_signal_handler(signal.SIGALRM, my_handler)
575575

576576
signal.setitimer(signal.ITIMER_REAL, 0.01, 0) # Send SIGALRM once.
577+
self.loop.call_later(60, self.loop.stop)
577578
self.loop.run_forever()
578579
self.assertEqual(caught, 1)
579580

@@ -586,11 +587,12 @@ def my_handler(*args):
586587
nonlocal caught
587588
caught += 1
588589
self.assertEqual(args, some_args)
590+
self.loop.stop()
589591

590592
self.loop.add_signal_handler(signal.SIGALRM, my_handler, *some_args)
591593

592594
signal.setitimer(signal.ITIMER_REAL, 0.1, 0) # Send SIGALRM once.
593-
self.loop.call_later(0.5, self.loop.stop)
595+
self.loop.call_later(60, self.loop.stop)
594596
self.loop.run_forever()
595597
self.assertEqual(caught, 1)
596598

0 commit comments

Comments
 (0)