New submission from Jakub Stasiak: It is my understanding that socket.sendall effectively calls the underlying socket.send's implementation in a retry loop, possibly multiple times.
It is also my understanding that each one of those low level send calls can timeout on its own if a socket timeout is set. Considering the above I believe it's undesired to ever call socket.sendall with a socket that has a timeout set because if: 1. At least one send call succeeds 2. A send call after that times out then a socket timeout error will be raised and the information about the sent data will be lost. Granted, the documentation says that "On error, an exception is raised, and there is no way to determine how much data, if any, was successfully sent". I believe, however, that such API is very easy to misuse (I've seen it used with sockets with timeout set, because of small payload sizes and other circumstances it would appear to work fine most of the time and only fail every N hours or days). Possible improvements I see: 1. Explicitly mention interaction between socket's timeout and sendall's behavior in the documentation 2. Make sendall raise an error when the socket it's called with has a timeout set (I can see the backwards compatibility being a concern here but I can't think of any reason to remain compatible with behavior I believe to be broken anyway) 3. Both of the above I'm happy to procure an appropriate patch for any of the above. Please correct me if my understanding of this is off. ---------- assignee: docs@python components: Documentation, IO, Library (Lib) messages: 254357 nosy: docs@python, jstasiak priority: normal severity: normal status: open title: socket.sendall broken when a socket has a timeout type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com