mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix gevent worker
This commit is contained in:
parent
f2920bfcda
commit
9a83d719b2
@ -12,6 +12,8 @@ from datetime import datetime
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
_socket = __import__("socket")
|
||||||
|
|
||||||
# workaround on osx, disable kqueue
|
# workaround on osx, disable kqueue
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
os.environ['EVENT_NOKQUEUE'] = "1"
|
os.environ['EVENT_NOKQUEUE'] = "1"
|
||||||
@ -22,7 +24,7 @@ except ImportError:
|
|||||||
raise RuntimeError("You need gevent installed to use this worker.")
|
raise RuntimeError("You need gevent installed to use this worker.")
|
||||||
from gevent.pool import Pool
|
from gevent.pool import Pool
|
||||||
from gevent.server import StreamServer
|
from gevent.server import StreamServer
|
||||||
from gevent.socket import wait_write
|
from gevent.socket import wait_write, socket
|
||||||
from gevent import pywsgi
|
from gevent import pywsgi
|
||||||
|
|
||||||
import gunicorn
|
import gunicorn
|
||||||
@ -63,7 +65,7 @@ class GeventWorker(AsyncWorker):
|
|||||||
server_class = None
|
server_class = None
|
||||||
wsgi_handler = None
|
wsgi_handler = None
|
||||||
|
|
||||||
def patch(cls):
|
def patch(self):
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.noisy = False
|
monkey.noisy = False
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
@ -71,6 +73,14 @@ class GeventWorker(AsyncWorker):
|
|||||||
# monkey patch sendfile to make it none blocking
|
# monkey patch sendfile to make it none blocking
|
||||||
patch_sendfile()
|
patch_sendfile()
|
||||||
|
|
||||||
|
# patch sockets
|
||||||
|
sockets = []
|
||||||
|
for s in self.sockets:
|
||||||
|
sockets.append(socket(s.FAMILY, _socket.SOCK_STREAM,
|
||||||
|
_sock=s))
|
||||||
|
self.sockets = sockets
|
||||||
|
|
||||||
|
|
||||||
def notify(self):
|
def notify(self):
|
||||||
super(GeventWorker, self).notify()
|
super(GeventWorker, self).notify()
|
||||||
if self.ppid != os.getppid():
|
if self.ppid != os.getppid():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user