(self)
| 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 |
nothing calls this directly
no test coverage detected