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