By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

No way to set a timeout in "urllib".

P: n/a
There's no way to set a timeout if you use "urllib" to open a URL.
"HTTP", which "urllib" uses, supports this, but the functionality
is lost at the "urllib" level.

It's not available via "class URLopener" or "FancyURLopener", either.

There is a non-thread-safe workaround from 2003 at

http://mail.python.org/pipermail/pyt...er/020405.html

but it was rejected as a feature at

https://sourceforge.net/tracker/?fun...&group_id=5470

without anything better going in. Despite this, current documentation
recommends that approach:

http://svn.python.org/projects/pytho...to/urllib2.rst

Someone proposed to fix this

http://mail.python.org/pipermail/pyt...ly/066967.html

but was discouraged from doing so.

The code was forked by Zope as a workaround in 2003:

http://pywebsvcs.sourceforge.net/api...s/Utility.html

but that's not in the mainstream Python tree.

The correct fix would probably be to add methods to class
URLopener to control this; that's the usual way of handling special
URL opening situations.

John Nagle
Dec 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

JohnThere's no way to set a timeout if you use "urllib" to open a URL.
John"HTTP", which "urllib" uses, supports this, but the functionality
Johnis lost at the "urllib" level.

John It's not available via "class URLopener" or "FancyURLopener",
John either.

JohnThere is a non-thread-safe workaround from 2003 at

...

This topic has come up several times since timeouts were added to socket.
Each time we've asked for a patch that adds timeouts in a rational manner to
all the stuff layered on top of the socket module (httplib, ftplib, etc). As
far as I know it's apparently never been important enough for anyone to rise
to the challenge. If I remember next spring perhaps I'll submit it as a
possible Google Summer of Code proposal.

JohnThe correct fix would probably be to add methods to class
JohnURLopener to control this; that's the usual way of handling
Johnspecial URL opening situations.

The correct way would be to deal with it at the httplib level, then
percolate it up to urllib2. Urllib should probably not be extended any
further.

Skip

Dec 30 '06 #2

P: n/a
sk**@pobox.com wrote:
JohnThere's no way to set a timeout if you use "urllib" to open a URL.
John"HTTP", which "urllib" uses, supports this, but the functionality
Johnis lost at the "urllib" level.

John It's not available via "class URLopener" or "FancyURLopener",
John either.

JohnThere is a non-thread-safe workaround from 2003 at

...

This topic has come up several times since timeouts were added to socket.
Each time we've asked for a patch that adds timeouts in a rational manner to
all the stuff layered on top of the socket module (httplib, ftplib, etc). As
far as I know it's apparently never been important enough for anyone to rise
to the challenge. If I remember next spring perhaps I'll submit it as a
possible Google Summer of Code proposal.
It ought not to take more than a day or two, although it is annoying
that you have to deal with the problem at several levels.

If you're looking for a Summer of Code project, consider finishing
the Python SSL library, which doesn't even check certificates, let alone
revocation lists. It's a pure interface problem. OpenSSL does all the
hard parts, but the Python glue code is crude and incomplete.

John Nagle
Dec 30 '06 #3

P: n/a

JohnIf you're looking for a Summer of Code project, ...

I'm not. I'm about 25 years out of grad school. ;-)

Skip
Dec 30 '06 #4

P: n/a
John Nagle <na***@animats.comwrites:
There's no way to set a timeout if you use "urllib" to open a URL.
"HTTP", which "urllib" uses, supports this, but the functionality
is lost at the "urllib" level.

It's not available via "class URLopener" or "FancyURLopener", either.

There is a non-thread-safe workaround from 2003 at

http://mail.python.org/pipermail/pyt...er/020405.html

but it was rejected as a feature at

https://sourceforge.net/tracker/?fun...&group_id=5470

without anything better going in. Despite this, current documentation
recommends that approach:

http://svn.python.org/projects/pytho...to/urllib2.rst
And...? What specifically are you complaining about?

Just as a matter of fact (I'm not grumpy about it): I see from your
message that you already know that there is not a shortage of people
who spot the lack of this kind of feature. The shortage is of people
who will actually do the job of adding the feature -- most
importantly, people who will contribute high quality patches,
including tests and docs, and people who will review other people's
patches.

Someone proposed to fix this

http://mail.python.org/pipermail/pyt...ly/066967.html

but was discouraged from doing so.
[...]

While it might be discouraging to be confronted with tiresome
realities of schedules and resources, those are the realities.

The flip side is that you can make a real difference by putting in
some work.

Looking forward to your patch :-)
John
Dec 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.