Giampaolo Rodola' added the comment:

New patch in attachment. Changes:

- docs

- replaced select() / poll() with the new selectors module

- file position is always updated both on return and on error; this means 
file.tell() is the designated way to know how many bytes were sent

- replaced sendall() with send() so that we can count the number of bytes 
transmitted (related and rejected proposal: 
https://mail.python.org/pipermail/python-ideas/2014-April/027689.html)

- send() now uses memoryview() for better performances to re-transmit data 
which was not sent by the first send() call

- pre-emptively raise exception if file is not opened in binary mode

- tests for ssl module

I've tried to work on Windows TransmitFile support but I got stuck as I'm not 
sure how to convert a file object into a HANDLE in C. I suppose Windows support 
can also be added later as a separate ticket and in the meantime I'd like to 
push this forward.

Open questions: 

- Is the current return value desirable (do we really care if os.sendfile() was 
used internally?)? Should the returned tuple also include the number 
transmitted bytes?

- default blocksize: Charles-François was suggesting to remove the blocksize 
argument; FWIW I've made some quick benchmarks by using "time" cmdline utility 
with different blocksizes and I didn't notice substantial difference. I still 
think a blocksize parameter is necessary in case we fallback on using send() 
and also for consistency with ftplib's storbinary() method which will be 
involved later (issue 13564).

----------
Added file: http://bugs.python.org/file34986/socket-sendfile3.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17552>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to