Skip to content

Commit

Permalink
Merge pull request #2172 from benoitc/issue1925
Browse files Browse the repository at this point in the history
Capture os.sendfile before patching in gevent and eventlet workers.
  • Loading branch information
jamadden committed Nov 13, 2019
2 parents 438371e + 902d9c8 commit 94ab209
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gunicorn/workers/geventlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
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)
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/workers/ggevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
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)
Expand Down

0 comments on commit 94ab209

Please sign in to comment.