Commit 84a695bc authored by Denis Bilenko's avatar Denis Bilenko

Hub: store/clear/restore current exc_info before/after switching

parent cc2fef3f
......@@ -144,13 +144,18 @@ class Hub(greenlet):
def switch(self):
cur = getcurrent()
assert cur is not self, 'Cannot switch to MAINLOOP from MAINLOOP'
switch_out = getattr(cur, 'switch_out', None)
if switch_out is not None:
try:
switch_out()
except:
traceback.print_exc()
return greenlet.switch(self)
exc_info = sys.exc_info()
try:
sys.exc_clear()
switch_out = getattr(cur, 'switch_out', None)
if switch_out is not None:
try:
switch_out()
except:
traceback.print_exc()
return greenlet.switch(self)
finally:
core.set_exc_info(*exc_info)
def run(self):
global _threadlocal
......
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