[Python-bugs-list] [ python-Bugs-614791 ] gethostbyname() blocks when threaded

noreply@sourceforge.net noreply@sourceforge.net
Thu, 26 Sep 2002 10:28:39 -0700


Bugs item #614791, was opened at 2002-09-25 23:44
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=614791&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Rob Green (rbgrn)
Assigned to: Nobody/Anonymous (nobody)
Summary: gethostbyname() blocks when threaded

Initial Comment:
I know this is because it is simply a wrapper for the libc 
gethostbyname, but it really, really hurts my app to have 
it block like this. I am requesting that by any means 
necessary, gethostbyname() not block when multiple 
threads call it simultaneously. It seriously ruins the 
ability to write effective network daemons in python, as it 
can take a very, very long time to get through even a 
small list of hostnames if one or a few of them need to 
timeout to be resolved.

----------------------------------------------------------------------

>Comment By: Rob Green (rbgrn)
Date: 2002-09-26 12:28

Message:
Logged In: YES 
user_id=590105

This is a little over my head, but I'll take a look to see what 
you mean. Could you give me any more info to point me in 
the right direction? Thanks

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-26 11:29

Message:
Logged In: YES 
user_id=21627

Bad choice of system :-) In general, it would be the easiest
modification of the interpreter to just release the GIL
before getaddrinfo (which gethostbyname uses); this is a
simple change and makes everything free running.

Unfortunately, on BSD, getaddrinfo is not thread-safe. So
for this system, a much more complicated change must be
implemented. I have semi-approved any change that releases
the GIL unconditionally on "good" systems (Solaris, Linux,
Tru64). That won't help you, though.

If you can contribute a patch that adds a getaddrinfo lock
for "bad" systems, and avoids this lock on "good" systems,
there is a small chance that this can get included in 2.2.2.
Without anybody acting quickly, this may or may not get
fixed in 2.3.

----------------------------------------------------------------------

Comment By: Rob Green (rbgrn)
Date: 2002-09-26 11:09

Message:
Logged In: YES 
user_id=590105

FreeBSD 4.5, although I don't think it's platform specific, as 
I've seen some messages from guido on certain mailing lists 
talking about this problem and how it will require a large 
rewrite to fix correctly. In all honesty, I'd be happy with a 
simple hack to make this work and then a rewrite of whatever 
needs it in the future to have it written correctly.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-26 11:06

Message:
Logged In: YES 
user_id=21627

Can you please report what platform you are using?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=614791&group_id=5470