[Python-bugs-list] [ python-Bugs-774751 ] slow socket binding & netinfo lookups
SourceForge.net
noreply@sourceforge.net
Mon, 21 Jul 2003 13:52:52 -0700
Bugs item #774751, was opened at 2003-07-21 01:57
Message generated for change (Comment added) made by jackjansen
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=774751&group_id=5470
Category: Macintosh
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Stuart Bishop (zenzen)
>Assigned to: Skip Montanaro (montanaro)
Summary: slow socket binding & netinfo lookups
Initial Comment:
The following code takes < 1 second to run under Python
2.1, but 20 seconds to run under Python 2.2 or 2.3 on a top-
end PowerBook running OSX 10.2. It is part of the Zope
startup routine.
def max_server_sockets():
sl = []
while 1:
try:
s = socket.socket (socket.AF_INET,
socket.SOCK_STREAM)
s.bind (('',0))
s.listen(5)
sl.append (s)
except:
break
num = len(sl)
for s in sl:
s.close()
del sl
return num
----------------------------------------------------------------------
>Comment By: Jack Jansen (jackjansen)
Date: 2003-07-21 22:52
Message:
Logged In: YES
user_id=45365
I have absolutely nothing to contribute wrt. this bug. As Just is
away I guess Skip is the best target for the hot patato.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-07-21 18:33
Message:
Logged In: YES
user_id=44345
Digging a bit deeper, it appears on Mac OS X that
fake_getaddrinfo is used. That's deemed not to be thread-safe.
I see three static or global variables acessed by this function:
firsttime - simple guard
translate - set inside the guard - readonly after that
faith_prefix - same
Why not push the guard and initialization code into init_socket
and protect it with the getaddrinfo lock? Fake_getaddrinfo
would thus be thread-safe and could be accessed without
acquiring a lock.
----------------------------------------------------------------------
Comment By: Skip Montanaro (montanaro)
Date: 2003-07-21 18:14
Message:
Logged In: YES
user_id=44345
whoops... my apologies for not posting here.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2003-07-21 17:50
Message:
Logged In: YES
user_id=31435
Attaching copious info from Skip Montanaro (skip.txt).
----------------------------------------------------------------------
Comment By: Anthony Baxter (anthonybaxter)
Date: 2003-07-21 09:05
Message:
Logged In: YES
user_id=29957
Is this something that should be looked at for 2.3rc2?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=774751&group_id=5470