You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
When running asyncio in debug mode (e.g. by setting environment variable
PYTHONASYNCIODEBUG) and trying Task.get_stack, an exception is raised because
the _CoroWrapper class is not a generator (I assume, not an expert on generator
internals). The attached file will reproduce this issue on asyncio 0.4.1.
The exception produced looks like this:
Traceback (most recent call last):
File "asyncio_stack_exc.py", line 14, in <module>
loop.run_until_complete(test_outer())
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/base_events.py", line 208, in run_until_complete
return future.result()
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/futures.py", line 243, in result
raise self._exception
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/tasks.py", line 283, in _step
result = next(coro)
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/tasks.py", line 50, in __next__
return next(self.gen)
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/tasks.py", line 84, in coro
res = func(*args, **kw)
File "asyncio_stack_exc.py", line 11, in test_outer
t.print_stack()
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/tasks.py", line 228, in print_stack
for f in self.get_stack(limit=limit):
File "/home/javex/.virtualenvs/misc/lib/python3.3/site-packages/asyncio/tasks.py", line 197, in get_stack
f = self._coro.gi_frame
AttributeError: 'CoroWrapper' object has no attribute 'gi_frame'
The source of the issue (roughly) is this line:
https://code.google.com/p/tulip/source/browse/asyncio/tasks.py#91
I think the most easy (but not necessarily the best) fix would be to modify the
"get_stack" method to check whether "self._coro"
(https://code.google.com/p/tulip/source/browse/asyncio/tasks.py#197) is an
instance of CoroWrapper (in the same manner the former half of iscoroutine
works https://code.google.com/p/tulip/source/browse/asyncio/tasks.py#110).
So one could do something like this:
if _DEBUG:
f = self._coro.gen.gi_frame
else:
f = self._coro.gi_frame
Which should work in this case. However, possibly some other code paths also
rely on the assumption that the coroutine actually is a generator directly so
maybe there are other places to fix.
Original issue reported on code.google.com by florian....@gmail.com on 31 Mar 2014 at 6:41
Original issue reported on code.google.com by
florian....@gmail.com
on 31 Mar 2014 at 6:41Attachments:
The text was updated successfully, but these errors were encountered: