You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.sendfile() on BSD, macOS don't return bytes sent on EINTR #80669
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2019-03-30.16:47:38.407>labels= ['3.7', '3.8', 'type-bug', 'library']
title="os.sendfile() on BSD, macOS don't return bytes sent on EINTR"updated_at=<Date2019-04-12.16:11:35.311>user='https://github.com/giampaolo'
<<[EINTR] A signal interrupted sendfile() before it could be completed. If specified, the number of bytes successfully sent will be returned in *len.>>
Right now we catch EINTR and simply retry. Instead we should only retry is no bytes were sent, else we should return those bytes, similarly to what we do on EAGAIN and EBUSY:
changed the title [-]BSD/OSX: os.sendfile() does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD OSs and macOS does not return bytes sent on EINTR[/+]on Mar 30, 2019
changed the title [-]os.sendfile() on BSD OSs and macOS does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD and macOS does not return bytes sent on EINTR[/+]on Mar 30, 2019
MojoVampire commented on Apr 1, 2019
MojoVampiremannequin
Mannequin
More actions
Wasn't the point of PEP-475 that all EINTR returns would be explicitly handled by retrying rather than forcing the user to handle it? Seems like the correct solution is still to retry, but on OSX/FreeBSD we'd need to update the offset and count arguments to account for the data that has already been sent.
changed the title [-]os.sendfile() on BSD and macOS does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD, macOS don't return bytes sent on EINTR[/+]on Apr 5, 2019
sendfile() on BSD/OSX is complicated by the headers/trailers args. You'll have to take that into account in the retry logic, adding unnecessary complexity. Since sendfile() may already return fewer bytes than requested (e.g. non-blocking sockets or big files) it's just easier to return the bytes sent thus far (if any). I can work on a patch once I find some time.
Wasn't the point of PEP-475 that all EINTR returns would be explicitly handled by retrying rather than forcing the user to handle it?
From PEP-475: <<[...] to relieve application code from the burden of doing so>>
MojoVampire commented on Apr 7, 2019
MojoVampiremannequin
Mannequin
More actions
Right. So this is a hard problem for anyone to solve, and therefore os.sendfile should be the one solving it, not the caller of sendfile, right?
Activity
giampaolo commentedon Mar 30, 2019
From "man sendfile" on both OSX and FreeBSD:
<<[EINTR] A signal interrupted sendfile() before it could be completed. If specified, the number of bytes successfully sent will be returned in *len.>>
Right now we catch EINTR and simply retry. Instead we should only retry is no bytes were sent, else we should return those bytes, similarly to what we do on EAGAIN and EBUSY:
cpython/Modules/posixmodule.c
Lines 8907 to 8917 in 2438cdf
[-]BSD/OSX: os.sendfile() does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD OSs and macOS does not return bytes sent on EINTR[/+][-]os.sendfile() on BSD OSs and macOS does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD and macOS does not return bytes sent on EINTR[/+]MojoVampire commentedon Apr 1, 2019
Wasn't the point of PEP-475 that all EINTR returns would be explicitly handled by retrying rather than forcing the user to handle it? Seems like the correct solution is still to retry, but on OSX/FreeBSD we'd need to update the offset and count arguments to account for the data that has already been sent.
[-]os.sendfile() on BSD and macOS does not return bytes sent on EINTR[/-][+]os.sendfile() on BSD, macOS don't return bytes sent on EINTR[/+]giampaolo commentedon Apr 5, 2019
sendfile() on BSD/OSX is complicated by the headers/trailers args. You'll have to take that into account in the retry logic, adding unnecessary complexity. Since sendfile() may already return fewer bytes than requested (e.g. non-blocking sockets or big files) it's just easier to return the bytes sent thus far (if any). I can work on a patch once I find some time.
From PEP-475: <<[...] to relieve application code from the burden of doing so>>
MojoVampire commentedon Apr 7, 2019
Right. So this is a hard problem for anyone to solve, and therefore os.sendfile should be the one solving it, not the caller of sendfile, right?