On Sunday, June 11, 2017 at 2:42:41 AM UTC-7, Lawrence D’Oliveiro wrote:
> I tried the following very simple script under both versions 3.5.3 and 3.6.1 
> of Python:
> 
>     import sys
>     import asyncio
> 
>     loop = asyncio.get_event_loop()
> 
>     async def idle() :
>         while True :
>             await asyncio.sleep(1)
>         #end while
>     #end idle
> 
>     loop.create_task(idle())
>     loop.run_forever()
> 
> After it starts running, I hit CTRL/C. Under both versions, I get the usual 
> KeyboardInterrupt exception and traceback. However, under 3.5, I also get 
> this:
> 
>     Task was destroyed but it is pending!
>     task: <Task pending coro=<idle() running at asyncio_loop_forever:14> 
> wait_for=<Future pending cb=[Task._wakeup()]>>
> 
> OK, as near as I can tell from the asyncio docs 
> <https://docs.python.org/3/library/asyncio.html>, it makes sense for this 
> message to appear. Yet it does not come up with 3.6. Was it deemed to be too 
> noisy, and too much trouble to silence, so it was quietly dropped?
> 
> Yet according to the 3.6 release notes 
> <https://docs.python.org/3/whatsnew/3.6.html#asyncio>, the changes to asyncio 
> have been backported to 3.5. So should there be a difference in behaviour 
> between the two?
> 
> I’m running Debian Unstable, so feel free to tell me 3.5.3 is obsolete and 
> there is some later 3.5.x version. ;)


My message in 3.5.3 is somewhat different, running Kubuntu 17.04:

>>> import sys
>>> import asyncio
>>> loop = asyncio.get_event_loop()

>>> async def idle():
...     while True:
...         await asyncio.sleep(1)
...     #end while
... #end idle
... 
>>> loop.create_task(idle())
<Task pending coro=<idle() running at <stdin>:1>>
>>> loop.run_forever()
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
    self._run_once()
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1388, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.5/selectors.py", line 445, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt
As yu can see, I get the  "Task pending coro=<idle()" messsage BEFORE I input 
the last line of instructions, and it comes from stdin.  Different terminals, 
perhaps?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to