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

Commit 7eef540

Browse files
miss-islingtonpablogsal
authored andcommitted
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 5471420) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent 216a4d8 commit 7eef540

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
@@ -557,6 +557,7 @@ def my_handler():
557557
self.loop.add_signal_handler(signal.SIGALRM, my_handler)
558558

559559
signal.setitimer(signal.ITIMER_REAL, 0.01, 0) # Send SIGALRM once.
560+
self.loop.call_later(60, self.loop.stop)
560561
self.loop.run_forever()
561562
self.assertEqual(caught, 1)
562563

@@ -569,11 +570,12 @@ def my_handler(*args):
569570
nonlocal caught
570571
caught += 1
571572
self.assertEqual(args, some_args)
573+
self.loop.stop()
572574

573575
self.loop.add_signal_handler(signal.SIGALRM, my_handler, *some_args)
574576

575577
signal.setitimer(signal.ITIMER_REAL, 0.1, 0) # Send SIGALRM once.
576-
self.loop.call_later(0.5, self.loop.stop)
578+
self.loop.call_later(60, self.loop.stop)
577579
self.loop.run_forever()
578580
self.assertEqual(caught, 1)
579581

0 commit comments

Comments
 (0)