Let's say you're uploading a file with a length of 113914 bytes at a default chunk size of 8192. On the last .read()
it'll block on data = self._sock.recv(left)
inside socket.py because 113914 - 106496
equals 7418
which is less than the block size of 8192
. It'll only release when the additional 774
bytes come in. (Hint™ they wont be coming)
The .read()
method inside socket.py should, in my opinion operate like the working example shown below where left is calculated by .tell()
(total content length of the socket) minus the size left in the buffer. If that is less than the size specified in .read()
use that as left.