Commit 05fdc001 authored by Denis Bilenko's avatar Denis Bilenko

Hub: do not catch the error in switch_out(). Use switch_out to prevent Hub to Hub switch

parent 7f5a562b
......@@ -277,21 +277,19 @@ class Hub(greenlet):
sys.stderr.write('%s failed with %s\n\n' % (context, getattr(type, '__name__', 'exception'), ))
def switch(self):
cur = getcurrent()
assert cur is not self, 'Impossible to call blocking function in the event loop callback'
exc_type, exc_value = sys.exc_info()[:2]
try:
switch_out = getattr(cur, 'switch_out', None)
switch_out = getattr(getcurrent(), 'switch_out', None)
if switch_out is not None:
try:
switch_out()
except:
self.handle_error(switch_out, *sys.exc_info())
switch_out()
exc_clear()
return greenlet.switch(self)
finally:
core.set_exc_info(exc_type, exc_value)
def switch_out(self):
raise AssertionError('Impossible to call blocking function in the event loop callback')
def wait(self, watcher):
unique = object()
watcher.start(getcurrent().switch, unique)
......
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