Commit 3a77f445 authored by Denis Bilenko's avatar Denis Bilenko

only use fork() if it's available; fix GreenletExit import error introduced in the prev commit

parent 3841c6f7
......@@ -29,5 +29,9 @@ spawn_link = Greenlet.spawn_link
spawn_link_value = Greenlet.spawn_link_value
spawn_link_exception = Greenlet.spawn_link_exception
from gevent.timeout import Timeout, with_timeout
from gevent.hub import getcurrent, sleep, kill, signal, fork, shutdown
from gevent.hub import getcurrent, GreenletExit, sleep, kill, signal, shutdown
try:
from gevent.hub import fork
except ImportError:
__all__.remove('fork')
from gevent.core import reinit
......@@ -26,7 +26,11 @@ thread = __import__('thread')
threadlocal = thread._local
_threadlocal = threadlocal()
_threadlocal.Hub = None
_original_fork = os.fork
try:
_original_fork = os.fork
except AttributeError:
_original_fork = None
__all__.remove('fork')
def sleep(seconds=0):
......@@ -69,10 +73,12 @@ def signal(signalnum, handler, *args, **kwargs):
return core.signal(signalnum, deliver_exception_to_MAIN)
def fork():
result = _original_fork()
core.reinit()
return result
if _original_fork is not None:
def fork():
result = _original_fork()
core.reinit()
return result
def shutdown():
......
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