Skip to content

Commit b400086

Browse files
asvetlovclaude
andcommitted
Check the handle left in the ready queue in test_run_forever_stop_in_carried_callbacks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e4ac2ae commit b400086

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Lib/test/test_asyncio/test_base_events.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ def stopper(loop):
14101410

14111411
def test_run_forever_stop_in_carried_callbacks(self):
14121412
calls = []
1413+
handle = None
14131414
self.loop._settings = asyncio.EventLoopSettings(
14141415
eager_max_time=60, eager_max_callbacks=1)
14151416

@@ -1419,8 +1420,9 @@ def first(loop):
14191420
loop.call_soon(calls.append, 'carried')
14201421

14211422
def eager(loop):
1423+
nonlocal handle
14221424
calls.append('eager')
1423-
loop.call_soon(calls.append, 'next')
1425+
handle = loop.call_soon(calls.append, 'next')
14241426

14251427
def stopper(loop):
14261428
calls.append('stopper')
@@ -1433,7 +1435,7 @@ def stopper(loop):
14331435
# the next _run_once(). stop() in them ends the loop after them, as
14341436
# without eager processing; the next iteration's callback is kept.
14351437
self.assertEqual(['eager', 'stopper', 'carried'], calls)
1436-
self.assertEqual(1, len(self.loop._ready))
1438+
self.assertEqual([handle], list(self.loop._ready))
14371439
self.assertEqual(self.loop._selector.select.call_count, 2)
14381440

14391441
def test_run_forever_stopped_before_start(self):

0 commit comments

Comments
 (0)