This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket intial recv() latency
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: arigo, desideratus, therve
Priority: normal Keywords:

Created on 2005-09-09 12:03 by desideratus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg26257 - (view) Author: Richard W (desideratus) Date: 2005-09-09 12:03
I have tested a socket client script on two versions of 
RedHat/Python and the later version is slow  to execute 
the initial recv().  In each test the client script was 
identical and the server end was the same Windows 
XML-ODBC service.  The code and strace below shows 
an initial recv taking 0.09 secs and 4.5 secs respectively.
The tests are repeatable with similar results each time.

Should I expect this kind of effect as software evolves or 
is there a solution?  Could it be internetwork latency as 
the clients tests were run on hosts in different locations?

-------------
import socket

host = "xx.xx.xx.xx"
port = xxxx
DSN  = "xxxx;UID=xxxx;"
length = 1024

Request = '''xxxxxxx'''

socket = socket.socket(socket.AF_INET, 
socket.SOCK_STREAM)
socket.connect((host,port))

XML = ''
EOM = '</Result>'

bytecount = socket.send(Request)
while  XML[-10:-1] != EOM: 
	XML += socket.recv(length)

socket.close()

------------------------------------------------------
strace results on client script run from command line:

1. RedHat Enterprise Linux 3 ES
Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2

[pid 14467] socket(PF_INET, SOCK_STREAM, 
IPPROTO_IP) = 3 <0.000028>
[pid 14467] rt_sigaction(SIGPIPE, {SIG_IGN}, 
{SIG_IGN}, 8) = 0 <0.000016>
[pid 14467] connect(3, {sa_family=AF_INET, 
sin_port=htons(xxxx), sin_addr=inet_addr("xx.xx.xx")}, 
16) = 0 <0.017305>
[pid 14467] send(3, "<?xml version=\"1.0\"?
>\r\n\t\t<Reques"..., 287, 0) = 287 <0.000025>
[pid 14467] recv(3, "<?xml version=\"1.0\" 
encoding=\"UT"..., 1024, 0) = 40 <0.093178>
[pid 14467] recv(3, "<!--\r\n  Generated by Easysoft 
XM"..., 1024, 0) = 378 <0.019240>
[pid 14467] close(3)                    = 0 <0.000027>

2. RedHat Enterprise Linux 4 ES
Python 2.3.4 (#1, Feb  2 2005, 11:44:49)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2

[pid 11072] socket(PF_INET, SOCK_STREAM, 
IPPROTO_IP) = 3 <0.000039>
[pid 11072] rt_sigaction(SIGPIPE, {SIG_IGN}, 
{SIG_IGN}, 8) = 0 <0.000011>
[pid 11072] connect(3, {sa_family=AF_INET, 
sin_port=htons(xxxx), sin_addr=inet_addr
("xx.xx.xx.xx")}, 16) = 0 <0.016039>
[pid 11072] send(3, "<?xml version=\"1.0\"?
>\r\n\t\t<Reques"..., 287, 0) = 287 <0.000021>
[pid 11072] recv(3, "<?xml version=\"1.0\" 
encoding=\"UT"..., 1024, 0) = 40 <4.539525>
[pid 11072] recv(3, "<!--\r\n  Generated by Easysoft 
XM"..., 1024, 0) = 378 <0.019317>
[pid 11072] close(3)                    = 0 <0.000069>






msg26258 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2005-09-25 12:05
Logged In: YES 
user_id=4771

You should try to run the script on two different versions
of Python from the same machine.  As far as we can tell,
your results seem to hint at a firewall or some network condition is stalling the connection from the second location, rather than Python arbitrarily waiting for 4.5 seconds -- which is a rather long time that would have been reported long ago if it really was caused by the Python interpreter only.
msg26259 - (view) Author: Richard W (desideratus) Date: 2005-10-20 15:50
Logged In: YES 
user_id=1342030

This was caused by the xml-odbc server end.  It was 
configured to do reverse dns lookups.  Turning them off cured 
the problem.  Lookups were obviously not efficient on moving 
to the new network.

As this is nothing to do with Python, RedHat etc. perhaps 
this bug should be deleted as it will not be much use to 
anyone.
msg58187 - (view) Author: Thomas Herve (therve) * Date: 2007-12-04 14:11
Can we close this one?
History
Date User Action Args
2022-04-11 14:56:13adminsetgithub: 42360
2007-12-06 12:55:50arigosetstatus: open -> closed
resolution: not a bug
2007-12-04 14:11:21thervesetnosy: + therve
messages: + msg58187
2005-09-09 12:03:56desideratuscreate