Commit 77bdffa4 authored by Denis Bilenko's avatar Denis Bilenko

add a comment in greenlet.py

parent d22eddc1
...@@ -280,6 +280,11 @@ class Greenlet(greenlet): ...@@ -280,6 +280,11 @@ class Greenlet(greenlet):
finally: finally:
t.cancel() t.cancel()
except: except:
# unlinking in 'except' instead of finally is an optimization:
# if switch occurred normally then link was already removed in _notify_links
# and there's no need to touch the links set.
# Note, however, that if "Invalid switch" assert was removed and invalid switch
# did happen, the link would remain, causing another invalid switch later in this greenlet.
self.unlink(switch) self.unlink(switch)
raise raise
if self.ready(): if self.ready():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment