[issue21340] Possible concurrency bug in asyncio, AttributeError in tasks.py

Guido van Rossum report at bugs.python.org
Fri Apr 25 08:45:16 CEST 2014


Guido van Rossum added the comment:

Oh wait, it looks like the assert failed because KeyboardInterrupt hit right at that point. I ran the program a few times and when I hit ^C I get a traceback at a different point in the code each time. This is as expected. You must have hit the rare case where it hit right at the assert -- then the behavior I described can happen.

Anyway, I think this would fix it:

--- a/asyncio/tasks.py  Fri Apr 18 09:51:35 2014 -0700
+++ b/asyncio/tasks.py  Thu Apr 24 23:44:57 2014 -0700
@@ -76,7 +76,8 @@
         return self.gen.gi_code

     def __del__(self):
-        frame = self.gen.gi_frame
+        gen = getattr(self, 'gen', None)
+        frame = getattr(gen, 'gi_frame', None)
         if frame is not None and frame.f_lasti == -1:
             func = self.func
             code = func.__code__

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21340>
_______________________________________


More information about the Python-bugs-list mailing list