473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

No way to set a timeout in "urllib".

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
4 6120

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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gilles Lenfant | last post by:
Hi, I make an app where I need to convert HTML to text in a "clever" way (means it tries to mimic when possible a browser rendering). Actually I spawn with popen2 a "lynx" that makes a perfect...
2
by: Eino Mäkitalo | last post by:
It seems that urrlib2 default redirection does not allow me to handle Cookies. Service I'm trying seems to use IP switcher and session id's with cookies. After successful login it changes session...
27
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a...
10
by: Pete | last post by:
I have the following code: <built-in method close of file object at 0xb7cc76e0> The file "temp.html" is created, but it doesn't look like the page at www.python.org. I'm guessing there are...
1
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
1
by: John Nagle | last post by:
I was looking at the code for "urllib", and there's some undocumented "FTP cacheing" code in there that's not thread safe. The documentation for "urllib" Is there any good reason to keep that...
8
by: John Nagle | last post by:
The Python documentation for "str" says "str() : Return a string containing a nicely printable representation of an object." However, there's no mention of the fact that "str" of a Unicode...
4
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, (sorry to begin with Java in a Python list ;-) in Java, when I want to pass input to a function, I pass "InputStream", which is a base class of any input stream. In Python, I found...
2
by: John Nagle | last post by:
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: False The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.