From 2ecbf9cf97fb082977a5f794fd622e360deba849 Mon Sep 17 00:00:00 2001 From: Jon Schlueter Date: Thu, 15 Aug 2019 10:20:01 -0400 Subject: [PATCH 1/6] Only install monotonic on python2 monotonic is a backport of time.monotonic from python3. Only install it for python2. --- eventlet/__init__.py | 8 ++++++-- eventlet/hubs/hub.py | 9 +++++++-- setup.py | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/eventlet/__init__.py b/eventlet/__init__.py index 1d33db0d72..fc876ef2f5 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -21,8 +21,12 @@ # 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: + import time + del time connect = convenience.connect listen = convenience.listen diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index 8871082edd..d6e670431d 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -22,7 +22,12 @@ 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 as now +except ImportError: + import time + now = time.monotonic + import six g_prevent_multiple_readers = True @@ -120,7 +125,7 @@ def __init__(self, clock=None): self.closed = [] if clock is None: - clock = monotonic.monotonic + clock = now self.clock = clock self.greenlet = greenlet.greenlet(self.run) diff --git a/setup.py b/setup.py index e61d289887..acc4241470 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.3"', 'six >= 1.10.0', ), zip_safe=False, From fde0fdcc8c80acf79d34b98d0409090869322d13 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 21 Oct 2020 11:04:32 +0300 Subject: [PATCH 2/6] !fixup --- eventlet/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eventlet/__init__.py b/eventlet/__init__.py index fc876ef2f5..e63c91dd27 100644 --- a/eventlet/__init__.py +++ b/eventlet/__init__.py @@ -25,8 +25,7 @@ import monotonic del monotonic except ImportError: - import time - del time + pass connect = convenience.connect listen = convenience.listen From ac13d373bd43c9762da4cccd40b4e35e02f1d148 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 21 Oct 2020 11:05:05 +0300 Subject: [PATCH 3/6] !fixup --- eventlet/hubs/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index d6e670431d..29bce93b06 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -23,7 +23,7 @@ def alarm_signal(seconds): from eventlet.hubs import timer from eventlet.support import greenlets as greenlet, clear_sys_exc_info try: - from monotonic import monotonic as now + from monotonic import monotonic except ImportError: import time now = time.monotonic From 1e93b7c9a0b2b57c5b433598b9cc8fae30e13c12 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 21 Oct 2020 11:05:45 +0300 Subject: [PATCH 4/6] !fixup --- eventlet/hubs/hub.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index 29bce93b06..fc61da94ff 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -25,8 +25,7 @@ def alarm_signal(seconds): try: from monotonic import monotonic except ImportError: - import time - now = time.monotonic + from time import monotonic import six From 520551110214276ed8b759e137bcea56ec428aee Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 21 Oct 2020 11:05:57 +0300 Subject: [PATCH 5/6] !fixup --- eventlet/hubs/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index fc61da94ff..fd28a540a7 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -124,7 +124,7 @@ def __init__(self, clock=None): self.closed = [] if clock is None: - clock = now + clock = monotonic self.clock = clock self.greenlet = greenlet.greenlet(self.run) From 9b3d98320d8603fd02482a6c05cfdf7590fc5d74 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 21 Oct 2020 19:41:51 +0300 Subject: [PATCH 6/6] !fixup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index acc4241470..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;python_version<"3.3"', + 'monotonic >= 1.4;python_version<"3.5"', 'six >= 1.10.0', ), zip_safe=False,