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

Method test_interrupt_wait

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

Source from the content-addressed store, hash-verified

439 runner.run(coro())
440
441 def test_interrupt_wait(self):
442 # interrupting when waiting a future cancels both future and main task
443 assert threading.current_thread() is threading.main_thread()
444
445 async def coro(fut):
446 with self.assertRaises(asyncio.CancelledError):
447 await fut
448 raise asyncio.CancelledError()
449
450 with asyncio.Runner() as runner:
451 fut = runner.get_loop().create_future()
452 runner.get_loop().call_later(0.1, interrupt_self)
453
454 with self.assertRaises(KeyboardInterrupt):
455 runner.run(coro(fut))
456
457 self.assertTrue(fut.cancelled())
458
459 def test_interrupt_cancelled_task(self):
460 # interrupting cancelled main task doesn't raise KeyboardInterrupt

Callers

nothing calls this directly

Calls 7

assertTrueMethod · 0.80
create_futureMethod · 0.45
get_loopMethod · 0.45
call_laterMethod · 0.45
assertRaisesMethod · 0.45
runMethod · 0.45
cancelledMethod · 0.45

Tested by

no test coverage detected