Author vstinner
Recipients irmen, loewis, pitrou, vstinner
Date 2015-09-03.15:47:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
recvall.patch: implement socket.socket.recvall() in pure Python.

It raises a new socket.IncompleteReadError (copied from asyncio) exception if the connection is closed before we got the expected number of bytes.

The patch has unit tests, document the new method and the new exception.

TODO: I don't like how the method handles timeout. The method must fail if it takes longer than socket.gettimeout() seconds, whereas currently the timeout is reset each time we got data from the server.

If the idea of the new socket method is accepted, I will reimplement it in C. In C, it's more easy to implement the timeout as I want.

In Python, the socket timeout cannot be changed temporary, because it would impact other threads which may use the same socket.

I changed how socket.sendall() handle timeout in Python 3.5, it is now the maximum total duration to send all data. The timeout is no more reset each time we send a packet. Related discussion:

See also the issue #23236 which adds a timeout reset each time we get data to the asyncio read() method. It will be complementary to the existing "wait(read(), timeout)" timeout method, it's for a different use case.
Date User Action Args
2015-09-03 15:47:43vstinnersetrecipients: + vstinner, loewis, irmen, pitrou
2015-09-03 15:47:43vstinnersetmessageid: <>
2015-09-03 15:47:43vstinnerlinkissue1103213 messages
2015-09-03 15:47:42vstinnercreate