urllib.urlopen blocking all threads for seconds when no connection or exception?

Robert k.robert at gmx.de
Fri Dec 13 07:44:47 EST 2002


Aahz wrote:
> In article <3df89a91$0$3028$9b622d9e at news.freenet.de>,
> Robert  <k.robert at gmx.de> wrote:
> 
>>Running the script below on windows (XP), when the computer has no 
>>connection to the site, urlopen blocks ALL other threads for seconds 
>>unpleasantly, as  shown in the output below. When the connection is 
>>there, everything seems to run smooth and seamless, regardless how 
>>time-consuming the urlopen or read is.
>>
>>is there a solution to this problem?
> 
> 
> Which version of Python is this?  (Probably doesn't matter, but I'm
> asking anyway.)  On many OSes, some calls are not thread-safe
> (gethostbyname() is a common one on Unix), and threads will block until
> that call returns.  You're probably hitting something like that; if so,
> there's not much Python can do.

its python 2.2.1 and WinXP.

yes the block is within gethostbyname()

I heard something of non-blocking socket operations. but I think it 
doesn't help here?
Think the only solitution would be to fork an other process? (what a mess)

the problem is that my GUI is blocked for seconds, when the bk-thread 
fails on www access.

robert






More information about the Python-list mailing list