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