An asyncio example

Adam Bartoš drekin at gmail.com
Sat Jul 4 03:04:07 EDT 2015


On Sat, Jul 4, 2015 at 8:45 AM, Adam Bartoš <drekin at gmail.com> wrote:

> On Fri, Jul 3, 2015 at 7:38 PM, Adam Bartoš <drekin at gmail.com> wrote:
>>>
>>>> Ian Kelly:
>>>>
>>> >> 2) In the blocked situaction even KeyboardInterrupt doesn't break the
>>>> loop
>>>>
>>> >> is that desired behavior? And why?
>>>>
>>> >
>>>>
>>> > I don't think so. When I tried this locally (using Python 3.4.0, so
>>>>
>>> > replacing "async def" with "def" and "await" with "yield from" and
>>>>
>>> > "loop.create_task" with "asyncio.async") pressing Ctrl-C did interrupt
>>>>
>>> > the loop
>>>>
>>> >
>>>>
>>> Ok, I'll try to get more information and I'll eventually raise an issue.
>>>>
>>>
>>>  I tried it on Python 3.4.1 and Ctrl-C doesn't interrupt the loop. Maybe
>>> it has something to do with the fact I'm on Windows.
>>
>>
>>  Please try with 3.4.3, which has further asyncio changes.
>>
>
> I originally tried with 3.5.0b2.
>
>

This is a minimal example:

import asyncio

async def wait():
    await asyncio.sleep(5)

loop = asyncio.get_event_loop()
loop.run_until_complete(wait())

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150704/95b8b1d2/attachment.html>


More information about the Python-list mailing list