diff --git a/eventlet/__init__.py b/eventlet/__init__.py index 1d33db0d72..e63c91dd27 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -21,8 +21,11 @@ # Helpful when CPython < 3.5 on Linux blocked in `os.waitpid(-1)` before first use of hub. # Example: gunicorn # https://github.com/eventlet/eventlet/issues/401#issuecomment-327500352 - import monotonic - del monotonic + try: + import monotonic + del monotonic + except ImportError: + pass connect = convenience.connect listen = convenience.listen diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index 8871082edd..fd28a540a7 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -22,7 +22,11 @@ def alarm_signal(seconds): import eventlet.hubs from eventlet.hubs import timer from eventlet.support import greenlets as greenlet, clear_sys_exc_info -import monotonic +try: + from monotonic import monotonic +except ImportError: + from time import monotonic + import six g_prevent_multiple_readers = True @@ -120,7 +124,7 @@ def __init__(self, clock=None): self.closed = [] if clock is None: - clock = monotonic.monotonic + clock = monotonic self.clock = clock self.greenlet = greenlet.greenlet(self.run) diff --git a/setup.py b/setup.py index e61d289887..ef28103d2a 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ 'dnspython >= 1.15.0', 'enum34;python_version<"3.4"', 'greenlet >= 0.3', - 'monotonic >= 1.4', + 'monotonic >= 1.4;python_version<"3.5"', 'six >= 1.10.0', ), zip_safe=False,