SocketServer and makefile()

Andy Bond bond at dstc.edu.au
Thu Aug 31 02:41:48 EDT 2000


I've been working with BaseHTTPServer which in turn uses SocketServer to
write a little web server.  It is used to accept PUT requests of 30MB chunks
of data.  I was having a problem where data was flowing at the rate of
something like 64K per second over a 100MB network.  Weird.  Further tracing
showed that the rfile variable from SocketServer (used to suck in data to
the http server) was created using makefile on the original socket
descriptor.  It was created with an option of zero for buffering (see
SocketServer.py) which means unbuffered.

Now some separate testing with socket.py showed that I could whip a 30MB
file across using plain sockets and send/recv but if I made the receivor use
makefile on the socket and then read, it slowed down to my 1 sec per 64K.
If I specify a buffer (something big but less than 64K ... IP packet size?)
then I am back in speedy territory.  The unbuffered mode seems almost like
it is sending the data 1 char at a time AND this is the default mode used in
SocketServer and subsequently BaseHTTPServer ...

This is on solaris 7, python 1.5.2.  Anyone else found this to be a problem
or am I doing something wrong?

andy





More information about the Python-list mailing list