Commit 980853da authored by Denis Bilenko's avatar Denis Bilenko

make reinit() and fork() only call loop.reinit() if there's a hub

parent 65396622
......@@ -41,16 +41,12 @@ from gevent.greenlet import Greenlet, joinall, killall
spawn = Greenlet.spawn
spawn_later = Greenlet.spawn_later
from gevent.timeout import Timeout, with_timeout
from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, signal
from gevent.hub import getcurrent, GreenletExit, spawn_raw, sleep, idle, kill, signal, reinit
try:
from gevent.hub import fork
except ImportError:
__all__.remove('fork')
def reinit():
return get_hub().loop.reinit()
def run(timeout=None, event=None):
return get_hub().join(timeout=timeout, event=event)
......@@ -18,6 +18,7 @@ __all__ = ['getcurrent',
'sleep',
'kill',
'signal',
'reinit',
'fork',
'get_hub',
'Hub',
......@@ -176,12 +177,18 @@ class signal(object):
self.hub.handle_error(None, *sys.exc_info())
def reinit():
hub = _get_hub()
if hub is not None:
hub.loop.reinit()
if _original_fork is not None:
def fork():
result = _original_fork()
if not result:
get_hub().loop.reinit()
reinit()
return result
......
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