Author giampaolo.rodola
Recipients asvetlov, christian.heimes, giampaolo.rodola, neologix, pitrou, rosslagerwall
Date 2013-04-08.15:14:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365434051.67.0.551798615728.issue17552@psf.upfronthosting.co.za>
In-reply-to
Content
New patch in attachment includes a new 'offset' parameter, new tests and also update file offset on return or in case of error so that file.tell() can be used to tell how many bytes were transmitted at any time.
This way we'll avoid using a custom exception.

In summary, the API looks like this.

Transfer ok:

>>> file = open('somefile', 'rb')
>>> s = socket.socket()
>>> sock.sendfile(file)
(True, None)
>>> file.tell()
20000000
>>>


...and in case sendfile() could not be used internally because file was not a regular file:

>>> file = io.BytesIO(b'x' * 1*1024*1024)
>>> sock.sendfile(file)
(False, UnsupportedOperation('fileno',))
>>> file.tell()
20000000
>>>


I still haven't looked into TransmitFile on Windows as I have to figure out how to compile Python 3.4 on Windows.
History
Date User Action Args
2013-04-08 15:14:11giampaolo.rodolasetrecipients: + giampaolo.rodola, pitrou, christian.heimes, asvetlov, neologix, rosslagerwall
2013-04-08 15:14:11giampaolo.rodolasetmessageid: <1365434051.67.0.551798615728.issue17552@psf.upfronthosting.co.za>
2013-04-08 15:14:11giampaolo.rodolalinkissue17552 messages
2013-04-08 15:14:11giampaolo.rodolacreate