mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Capture os.sendfile before patching in gevent and eventlet workers.
Fixes #1925 and fixes #2170.
This commit is contained in:
parent
438371ee90
commit
902d9c89ab
@ -26,10 +26,10 @@ import greenlet
|
||||
from gunicorn.workers.base_async import AsyncWorker
|
||||
|
||||
|
||||
def _eventlet_sendfile(fdout, fdin, offset, nbytes):
|
||||
def _eventlet_sendfile(fdout, fdin, offset, nbytes, _os_sendfile=os.sendfile):
|
||||
while True:
|
||||
try:
|
||||
return os.sendfile(fdout, fdin, offset, nbytes)
|
||||
return _os_sendfile(fdout, fdin, offset, nbytes)
|
||||
except OSError as e:
|
||||
if e.args[0] == errno.EAGAIN:
|
||||
trampoline(fdout, write=True)
|
||||
|
||||
@ -30,10 +30,10 @@ from gunicorn.workers.base_async import AsyncWorker
|
||||
VERSION = "gevent/%s gunicorn/%s" % (gevent.__version__, gunicorn.__version__)
|
||||
|
||||
|
||||
def _gevent_sendfile(fdout, fdin, offset, nbytes):
|
||||
def _gevent_sendfile(fdout, fdin, offset, nbytes, _os_sendfile=os.sendfile):
|
||||
while True:
|
||||
try:
|
||||
return os.sendfile(fdout, fdin, offset, nbytes)
|
||||
return _os_sendfile(fdout, fdin, offset, nbytes)
|
||||
except OSError as e:
|
||||
if e.args[0] == errno.EAGAIN:
|
||||
socket.wait_write(fdout)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user