New submission from Jack Murray:

AttributeError in /usr/lib/python3.4/asyncio/tasks.py feels like it might be a 
concurrency issue. I can't reproduce it, and my python isn't good enough to 
know how to simulate raising the exception at a random time during the 
execution of the program. Here's the PoC:

import asyncio
import sys
from asyncio import async
import time
import random
asyncio.tasks._DEBUG = True


loop = asyncio.get_event_loop()

def read_something():
  print(input())

@asyncio.coroutine
def func(arg):
  while True:
    sys.stdout.write("\rtest"+str(arg))
    yield from asyncio.sleep(0)

loop.add_reader(sys.stdin, read_something)
loop.call_soon(async, func(1))
loop.call_soon(async, func(2))
loop.call_soon(async, func(3))
loop.call_soon(async, func(4))

time.sleep(1)

try:
  loop.run_forever()
except KeyboardInterrupt:
  print("handled\n")
  pass
finally:
  pass

and here is the stack trace:

ktn:~/ $ python asynctest.py                                                    
                                   [11:55:03]
test3^Chandled

Future/Task exception was never retrieved
future: Task(<func>)<exception=KeyboardInterrupt()>
Traceback (most recent call last):
  File "asynctest.py", line 29, in <module>
    loop.run_forever()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 184, in run_forever
    self._run_once()
  File "/usr/lib/python3.4/asyncio/base_events.py", line 800, in _run_once
    handle._run()
  File "/usr/lib/python3.4/asyncio/events.py", line 39, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 337, in _wakeup
    self._step(value, None)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 283, in _step
    result = next(coro)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 50, in __next__
    return next(self.gen)
  File "asynctest.py", line 18, in func
    yield from asyncio.sleep(0)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 94, in wrapper
    w = CoroWrapper(coro(*args, **kwds), func)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 42, in __init__
    assert inspect.isgenerator(gen), gen
KeyboardInterrupt
Exception ignored in: <bound method CoroWrapper.__del__ of 
<asyncio.tasks.CoroWrapper object at 0x7f0dedaf79d8>>
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 62, in __del__
    frame = self.gen.gi_frame
AttributeError: gen

----------
messages: 217112
nosy: Jack.Murray
priority: normal
severity: normal
status: open
title: Possible bug in asyncio
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21340>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to