urllib2.urlopen timeout

Z

Zdenek Maxa

Hi,

I would like to ask how I should set timeout for a call:

f = urllib2.urlopen(url)

I am using Python 2.5. I have already tried
socket.setdefaulttimeout(3). However, this adversely affects other
connections the application makes, since it seems to affect all socket
connections.

I know that Python 2.6 offers
urllib2.urlopen(url[, data][, timeout])
which would elegantly solved my problem, but I have to stick to Python 2.5.

I am doing urlopen in a thread so I want to avoid really long hanging on
this call, which happens at times, until some default timeout ticks out.

All hints appreciated.

Thanks,
Zdenek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top