homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jack.Murray
Recipients Jack.Murray
Date 2014年04月24日.02:13:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398305622.34.0.507325141901.issue21340@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014年04月24日 02:13:42Jack.Murraysetrecipients: + Jack.Murray
2014年04月24日 02:13:42Jack.Murraysetmessageid: <1398305622.34.0.507325141901.issue21340@psf.upfronthosting.co.za>
2014年04月24日 02:13:42Jack.Murraylinkissue21340 messages
2014年04月24日 02:13:41Jack.Murraycreate

AltStyle によって変換されたページ (->オリジナル) /