MCPcopy Index your code
hub / github.com/python/cpython / test_interrupt_call_soon

Method test_interrupt_call_soon

Lib/test/test_asyncio/test_runners.py:425–439  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

423 runner.run(f())
424
425 def test_interrupt_call_soon(self):
426 # The only case when task is not suspended by waiting a future
427 # or another task
428 assert threading.current_thread() is threading.main_thread()
429
430 async def coro():
431 with self.assertRaises(asyncio.CancelledError):
432 while True:
433 await asyncio.sleep(0)
434 raise asyncio.CancelledError()
435
436 with asyncio.Runner() as runner:
437 runner.get_loop().call_later(0.1, interrupt_self)
438 with self.assertRaises(KeyboardInterrupt):
439 runner.run(coro())
440
441 def test_interrupt_wait(self):
442 # interrupting when waiting a future cancels both future and main task

Callers

nothing calls this directly

Calls 4

call_laterMethod · 0.45
get_loopMethod · 0.45
assertRaisesMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected