| |
@@ -0,0 +1,141 @@
|
| |
+ From d5ce78c2440c3c27f3369c7b5c7c787ec1aa0cd5 Mon Sep 17 00:00:00 2001
|
| |
+ From: Carl George <carl@george.computer>
|
| |
+ Date: Thu, 31 Aug 2023 15:57:22 -0500
|
| |
+ Subject: [PATCH 2/3] Restore compatibility with older gevent
|
| |
+
|
| |
+ Upstream added a runtime check for gevent 1.4 in gunicorn 20.0.0.
|
| |
+ However, they didn't enforce this minimum version at install time in
|
| |
+ setup.py until gunicorn 20.1.0. This resulted in gunicorn 20.0.4 being
|
| |
+ added to EPEL 8, even though RHEL 8 only has gevent 1.2.2. This commit
|
| |
+ removes that runtime check and the other corresponding changes so that
|
| |
+ gunicorn 20.0.4 works with gevent 1.2.2.
|
| |
+
|
| |
+ Partially revert "Bump minimum Eventlet and Gevent versions (#1962)"
|
| |
+
|
| |
+ This partially reverts commit 9f87c88819b901d4cd8ddf6c2bba1198b68903cb.
|
| |
+ ---
|
| |
+ gunicorn/config.py | 2 +-
|
| |
+ gunicorn/workers/ggevent.py | 61 ++++++++++++++++++++++++++++---------
|
| |
+ 2 files changed, 48 insertions(+), 15 deletions(-)
|
| |
+
|
| |
+ diff --git a/gunicorn/config.py b/gunicorn/config.py
|
| |
+ index 0db1a311..2ef1776d 100644
|
| |
+ --- a/gunicorn/config.py
|
| |
+ +++ b/gunicorn/config.py
|
| |
+ @@ -641,7 +641,7 @@ class WorkerClass(Setting):
|
| |
+ * ``sync``
|
| |
+ * ``eventlet`` - Requires eventlet >= 0.24.1 (or install it via
|
| |
+ ``pip install gunicorn[eventlet]``)
|
| |
+ - * ``gevent`` - Requires gevent >= 1.4 (or install it via
|
| |
+ + * ``gevent`` - Requires gevent >= 0.13 (or install it via
|
| |
+ ``pip install gunicorn[gevent]``)
|
| |
+ * ``tornado`` - Requires tornado >= 0.2 (or install it via
|
| |
+ ``pip install gunicorn[tornado]``)
|
| |
+ diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py
|
| |
+ index 85418035..b0d158d2 100644
|
| |
+ --- a/gunicorn/workers/ggevent.py
|
| |
+ +++ b/gunicorn/workers/ggevent.py
|
| |
+ @@ -10,18 +10,20 @@ from datetime import datetime
|
| |
+ from functools import partial
|
| |
+ import time
|
| |
+
|
| |
+ +_socket = __import__("socket")
|
| |
+ +
|
| |
+ +# workaround on osx, disable kqueue
|
| |
+ +if sys.platform == "darwin":
|
| |
+ + os.environ['EVENT_NOKQUEUE'] = "1"
|
| |
+ +
|
| |
+ try:
|
| |
+ import gevent
|
| |
+ except ImportError:
|
| |
+ - raise RuntimeError("gevent worker requires gevent 1.4 or higher")
|
| |
+ -else:
|
| |
+ - from pkg_resources import parse_version
|
| |
+ - if parse_version(gevent.__version__) < parse_version('1.4'):
|
| |
+ - raise RuntimeError("gevent worker requires gevent 1.4 or higher")
|
| |
+ -
|
| |
+ + raise RuntimeError("You need gevent installed to use this worker.")
|
| |
+ from gevent.pool import Pool
|
| |
+ from gevent.server import StreamServer
|
| |
+ -from gevent import hub, monkey, socket, pywsgi
|
| |
+ +from gevent.socket import wait_write, socket
|
| |
+ +from gevent import pywsgi
|
| |
+
|
| |
+ import gunicorn
|
| |
+ from gunicorn.http.wsgi import base_environ
|
| |
+ @@ -36,7 +38,7 @@ def _gevent_sendfile(fdout, fdin, offset, nbytes, _os_sendfile=os.sendfile):
|
| |
+ return _os_sendfile(fdout, fdin, offset, nbytes)
|
| |
+ except OSError as e:
|
| |
+ if e.args[0] == errno.EAGAIN:
|
| |
+ - socket.wait_write(fdout)
|
| |
+ + wait_write(fdout)
|
| |
+ else:
|
| |
+ raise
|
| |
+
|
| |
+ @@ -50,7 +52,14 @@ class GeventWorker(AsyncWorker):
|
| |
+ wsgi_handler = None
|
| |
+
|
| |
+ def patch(self):
|
| |
+ - monkey.patch_all()
|
| |
+ + from gevent import monkey
|
| |
+ + monkey.noisy = False
|
| |
+ +
|
| |
+ + # if the new version is used make sure to patch subprocess
|
| |
+ + if gevent.version_info[0] == 0:
|
| |
+ + monkey.patch_all()
|
| |
+ + else:
|
| |
+ + monkey.patch_all(subprocess=True)
|
| |
+
|
| |
+ # monkey patch sendfile to make it none blocking
|
| |
+ patch_sendfile()
|
| |
+ @@ -58,7 +67,7 @@ class GeventWorker(AsyncWorker):
|
| |
+ # patch sockets
|
| |
+ sockets = []
|
| |
+ for s in self.sockets:
|
| |
+ - sockets.append(socket.socket(s.FAMILY, socket.SOCK_STREAM,
|
| |
+ + sockets.append(socket(s.FAMILY, _socket.SOCK_STREAM,
|
| |
+ fileno=s.sock.fileno()))
|
| |
+ self.sockets = sockets
|
| |
+
|
| |
+ @@ -156,10 +165,34 @@ class GeventWorker(AsyncWorker):
|
| |
+ # by deferring to a new greenlet. See #1645
|
| |
+ gevent.spawn(super().handle_usr1, sig, frame)
|
| |
+
|
| |
+ - def init_process(self):
|
| |
+ - self.patch()
|
| |
+ - hub.reinit()
|
| |
+ - super().init_process()
|
| |
+ + if gevent.version_info[0] == 0:
|
| |
+ +
|
| |
+ + def init_process(self):
|
| |
+ + # monkey patch here
|
| |
+ + self.patch()
|
| |
+ +
|
| |
+ + # reinit the hub
|
| |
+ + import gevent.core
|
| |
+ + gevent.core.reinit()
|
| |
+ +
|
| |
+ + #gevent 0.13 and older doesn't reinitialize dns for us after forking
|
| |
+ + #here's the workaround
|
| |
+ + gevent.core.dns_shutdown(fail_requests=1)
|
| |
+ + gevent.core.dns_init()
|
| |
+ + super(GeventWorker, self).init_process()
|
| |
+ +
|
| |
+ + else:
|
| |
+ +
|
| |
+ + def init_process(self):
|
| |
+ + # monkey patch here
|
| |
+ + self.patch()
|
| |
+ +
|
| |
+ + # reinit the hub
|
| |
+ + from gevent import hub
|
| |
+ + hub.reinit()
|
| |
+ +
|
| |
+ + # then initialize the process
|
| |
+ + super(GeventWorker, self).init_process()
|
| |
+
|
| |
+
|
| |
+ class GeventResponse(object):
|
| |
+ --
|
| |
+ 2.41.0
|
| |
+
|
| |
Resolves rhbz#2234825