[Python-Dev] socket recv on win32 can be extremly delayed (python bug?)

Robert Hölzl robert.hoelzl at baltech.de
Thu Apr 17 12:08:41 CEST 2008


I tried to implement a simple python XMLRPC service on a win32 
environment (client/server code inserted below).
The profiler of the client told me, that a simple function call needs 
about 200ms (even if I run it in a loop, the time needed per call stays 
the same).

After analysing the problem with etherreal I found out, that the XMLRPC 
request is transmitted via two TCP packets. One containing the HTTP 
header and one containting the data. But the acknowledge to the first 
TCP packet is delayed by 200ms.

I tried around on the server side and found out that if the server reads 
exactly all bytes transfered in the first TCP frame (via socket.recv()), 
the next socket.recv(), even if reading only one byte, needs about 200 
ms. But if I read one byte less than transfered in the first TCP frame 
and then reading 2 bytes (socket.recv(2)) there is no delay, although 
the same total amount of data was read.

After some googling I found the website 
http://support.microsoft.com/?scid=kb%3Ben-us%3B823764&x=12&y=15, which 
proposed a workaround (modifing the registryentry for the tcp/ip driver) 
that did work. But modifing the clients registry settings is no option 
for us.

Is there anybody who nows how to solve the problem? Or is it even a 
problem if the python socket implementation?

By the way: I testet Win2000 SP4 and WinXP SP2 with Python 2.3.3 and 
Python 2.5.1 each.

import xmlrpclib
import profile
server = xmlrpclib.ServerProxy("http://server:80")

import SimpleXMLRPCServer
def test(a,b): return a+b
server = SimpleXMLRPCServer.SimpleXMLRPCServer( ('', 80) )

Mit freundlichen Grüßen,
Best Regards,

Robert Hölzl

Firmensitz: Lilienthalstrasse 27, D-85399 Hallbergmoos
Registergericht: Amtsgericht München, HRB 115215
Vorstand: Jürgen Rösch (Vorsitzender), Martina M. Schuster
Aufsichtsratsvorsitzende: Eva Zeising

-------------- next part --------------
A non-text attachment was scrubbed...
Name: robert_hoelzl.vcf
Type: text/x-vcard
Size: 569 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20080417/535c5441/attachment-0001.vcf>

More information about the Python-Dev mailing list