[Python-Dev] urllib performance issue on FreeBSD 4.x

Martin v. Loewis martin@v.loewis.de
24 Nov 2002 09:43:38 +0100

Andrew MacIntyre <andymac@bullseye.apana.org.au> writes:

> - why is the socket.fp being set to unbuffered?

I believe it prevents deadlocks. In HTTP/1.1, the server may not close
the connection, but may refuse to send more data until it receives the
next command. So you must be very careful to not read more data from
the socket than the protocol guarantees you to be present.

I believe stdio would not apply the necessary care: if it wants to
fill the buffer, it will block. It won't see EOF because there is
none, but there won't be any more data, because the server won't send
any until we send the next command. We won't send the next command,
since we are blocked.