mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #2172 from benoitc/issue1925
Capture os.sendfile before patching in gevent and eventlet workers.
This commit is contained in:
commit
94ab209117
@ -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