<div dir="ltr">I think this may be more of a Windows issue than an asyncio issue. I agree that ideally ^C should take effect immediately (as it does on UNIX).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 4, 2015 at 9:54 AM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Should the loop.run... methods of asyncio respect KeyboardInterrupt (^C)?<br>
<br>
Developer and user convenience and this paragraph in PEP<br>
<br>
"However, exceptions deriving only from BaseException are typically not caught, and will usually cause the program to terminate with a traceback. In some cases they are caught and re-raised. (Examples of this category include KeyboardInterrupt and SystemExit ; it is usually unwise to treat these the same as most other exceptions.) "<br>
<br>
and this examples in the doc (two places)<br>
<br>
TCP echo server<br>
# Serve requests until CTRL+c is pressed<br>
print('Serving on {}'.format(server.sockets[0].getsockname()))<br>
try:<br>
loop.run_forever()<br>
except KeyboardInterrupt:<br>
pass<br>
<br>
suggest yes. On the other hand, the section on<br>
"Set signal handlers for SIGINT and SIGTERM"<br>
suggests not, unless an explicit handler is registered and then only on Unix.<br>
<br>
In any case, Adam Bartos, python-list, "An asyncio example", today asks.<br>
'''<br>
This is a minimal example:<br>
<br>
import asyncio<br>
<br>
async def wait():<br>
await asyncio.sleep(5)<br>
<br>
loop = asyncio.get_event_loop()<br>
loop.run_until_complete(wait())<br>
<br>
Ctrl-C doesn't interrupt the waiting, instead KeyboardInterrupt occurs after those five seconds. It's 3.5.0b2 on Windows. Is it a bug?<br>
'''<br>
<br>
Using run_forever instead, I found no way to stop other than killing the process (Idle or Command Prompt).<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Terry Jan Reedy<br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>