Message301611
Attempting to clarify what Greg & I think the right answer will be for the async context management case: https://docs.python.org/3/library/asyncio-eventloop.html#unix-signals
In practice, that would look something like:
```
>>> loop = asyncio.get_event_loop()
>>> def sigint_handler():
... raise KeyboardInterrupt
...
>>> loop.add_signal_handler(signal.SIGINT, sigint_handler)
>>> loop.run_forever()
Traceback (most recent call last):
...
KeyboardInterrupt
```
That way, dealing gracefully with KeyboardInterrupt is wholly under the event loop's control, rather than the event loop having to fight with the eval loop as to how Ctrl-C should be handled. |
|
Date |
User |
Action |
Args |
2017-09-07 18:48:57 | ncoghlan | set | recipients:
+ ncoghlan, gregory.p.smith, njs, Mark.Shannon, erik.bray, jdemeyer, yselivanov, deleted0524, xgdomingo |
2017-09-07 18:48:57 | ncoghlan | set | messageid: <1504810137.79.0.201622687275.issue29988@psf.upfronthosting.co.za> |
2017-09-07 18:48:57 | ncoghlan | link | issue29988 messages |
2017-09-07 18:48:57 | ncoghlan | create | |
|