Commits

Armin Rigo  committed e0b2d98

permute() should also ignore non-initialized continulets,
just like switch().

  • Participants
  • Parent commits dfae503

Comments (0)

Files changed (3)

File lib_pypy/greenlet.py

     try:
         res = greenlet.run(*args)
     finally:
-        if greenlet.parent is not _tls.main:
-            _continuation.permute(greenlet, greenlet.parent)
+        _continuation.permute(greenlet, greenlet.parent)
     return (res,)
 
 def _greenlet_throw(greenlet, exc, value, tb):
     try:
         raise exc, value, tb
     finally:
-        if greenlet.parent is not _tls.main:
-            _continuation.permute(greenlet, greenlet.parent)
+        _continuation.permute(greenlet, greenlet.parent)

File pypy/module/_continuation/interp_continuation.py

         cont = space.interp_w(W_Continulet, w_cont)
         if cont.sthread is not sthread:
             if cont.sthread is None:
-                raise geterror(space, "got a non-initialized continulet")
+                continue   # ignore non-initialized continulets
             else:
                 raise geterror(space, "inter-thread support is missing")
         elif sthread.is_empty_handle(cont.h):

File pypy/module/_continuation/test/test_stacklet.py

             assert res == "done"
         main()
 
+    def test_permute_noninitialized(self):
+        from _continuation import continulet, permute
+        permute(continulet.__new__(continulet))    # ignored
+        permute(continulet.__new__(continulet),    # ignored
+                continulet.__new__(continulet))
+
     def test_bug_finish_with_already_finished_stacklet(self):
         from _continuation import continulet, error
         # make an already-finished continulet