urllib2 problem

John J. Lee jjl at pobox.com
Fri Oct 28 14:42:54 EDT 2005


"Jeremy Martin" <Jeremy.Martin at noaa.gov> writes:
[...]
> website. I originally just used urllib.urlopen and everything worked 
> fine on my Windows PC at work. I tried the same script at home on my 
> Fedora COre 3 box using python 2.4, and whenever I try to connect to 
> the site I get the (110, Connection Timed Out) Error.  
> 
> At first I thought my firewall was causing problems with the script but 
> I noticed an odd patten. If the web site asked to accept cookies (like 
> the site I need) the script times out), if I point it to a site that 
> doesnt it works fine. Ive tried several attempts at using urllib2 and 
> the HTTPCookieProccessor and I still have no luck.

If this is just a single server you're talking to, this doesn't
necessarily implicate HTTPCookieProccessor -- it may be that that
server does different stuff depending on whether you return cookies or
not (not much point in having the cookies if not ;-), so the timeout
might be caused by all kinds of unrelated problems.


> Can anyone give me 
> any advice or pointers on what may be the problem here? I apologize if 
> this is kind of a rookie question but Ive been searching for about a 
> week with no luck. 

I'm the author of cookielib and HTTPCookieProccessor.  It's very hard
to guess what's wrong without being able to reproduce the problem.  If
you can send me your script (jjl at pobox.com), I may be able to help.

One point, though.  This doesn't seem to be the problem you are
having, but it's a good thing for this info to be more easily
Google-able for others: Are you using threads?  cookielib is
thread-broken, I suspect (poorly-tested thread support code was left
in when I contributed the module, which was a mistake: I'm almost
certain it's incorrect, and intend to request the thread
synchronisation code be removed in 2.5).  I suspect that could cause
deadlock if you are using threads.  It's probably possible to work
around this, but I reccommend just not using threads (and not only
because of my buggy synchronisation code!).  But as I say, I don't
think this is your problem.


John




More information about the Python-list mailing list