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

Mike Klaas mike.klaas at gmail.com
Wed Apr 23 01:11:29 CEST 2008


Hi,

This is not a python-specific problem. See
http://en.wikipedia.org/wiki/Nagle's_algorithm

-Mike

On 17-Apr-08, at 3:08 AM, Robert Hölzl wrote:
> hello,
>
> 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.
>
> CLIENT:
> ----------
> import xmlrpclib
> import profile
> server = xmlrpclib.ServerProxy("http://server:80")
> profile.run('server.test(1,2)')
>
> SERVER:
> ----------
> import SimpleXMLRPCServer
> def test(a,b): return a+b
> server = SimpleXMLRPCServer.SimpleXMLRPCServer( ('', 80) )
> server.register_function(test)
> server.serve_forever()
>
> -- 
> Mit freundlichen Grüßen,
> Best Regards,
>
> Robert Hölzl
> BALTECH AG
>
> Firmensitz: Lilienthalstrasse 27, D-85399 Hallbergmoos
> Registergericht: Amtsgericht München, HRB 115215
> Vorstand: Jürgen Rösch (Vorsitzender), Martina M. Schuster
> Aufsichtsratsvorsitzende: Eva Zeising
>
> <robert_hoelzl.vcf>_______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/mike.klaas%40gmail.com



More information about the Python-Dev mailing list