diff options
author | Jon Schlueter <jon.schlueter@gmail.com> | 2020-10-21 21:42:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 04:42:41 +0300 |
commit | e918595a8ffc241a851ff270a6279d6a9c1797b7 (patch) | |
tree | 87d35a11648669d6a75f1e2111988d0ba641a478 | |
parent | 7b1aa58d77550caabba3ca2e0b1bb79626c83d9c (diff) | |
download | eventlet-e918595a8ffc241a851ff270a6279d6a9c1797b7.tar.gz |
Only install monotonic on python2 (#583)
Only install monotonic on python<3.5
Co-authored-by: Sergey Shepelev <temotor@gmail.com>
-rw-r--r-- | eventlet/__init__.py | 7 | ||||
-rw-r--r-- | eventlet/hubs/hub.py | 8 | ||||
-rw-r--r-- | setup.py | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/eventlet/__init__.py b/eventlet/__init__.py index 042791f..8e12579 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -21,8 +21,11 @@ if os.environ.get('EVENTLET_IMPORT_VERSION_ONLY') != '1': # 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 375f35e..db55958 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -22,7 +22,11 @@ else: 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 @@ class BaseHub(object): self.closed = [] if clock is None: - clock = monotonic.monotonic + clock = monotonic self.clock = clock self.greenlet = greenlet.greenlet(self.run) @@ -17,7 +17,7 @@ setuptools.setup( install_requires=( 'dnspython >= 1.15.0, < 2.0.0', 'greenlet >= 0.3', - 'monotonic >= 1.4', + 'monotonic >= 1.4;python_version<"3.5"', 'six >= 1.10.0', ), zip_safe=False, |