This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2.py timeouts do not propagate across redirects for 2.6.1 (and 3.x?)
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: ggenellina, j_mcneil, jacques, jjlee, orsenthil, r.david.murray
Priority: normal Keywords: easy, patch

Created on 2009-01-29 22:34 by jacques, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2_timeouts.diff j_mcneil, 2009-06-12 19:24 Added timeouts to retry methods.
Messages (6)
msg80787 - (view) Author: Jacques Grove (jacques) Date: 2009-01-29 22:34
When doing a urllib2 fetch of a url that results in a redirect, the
connection to the redirect does not pass along the timeout of the
original url opener.  The result is that the redirected url fetch (which
is a new request) will get the default socket timeout, instead of the
timeout that the user requested originally.  This is obviously a bug.

So we have in urllib2.py in 2.6.1:

def http_error_302(self, req, fp, code, msg, headers):
.....
    return self.parent.open(new)

this should be:
    return self.parent.open(new, timeout=req.timeout)

or something in that vein.


Of course, to be 100% correct, you should probably keep track of how
much time has elapsed since the original url fetch went out, and reduce
the timeout based on this, but I'm not asking for miracles :-)


Jacques
msg89296 - (view) Author: Jeff McNeil (j_mcneil) Date: 2009-06-12 19:24
I ran into this problem this afternoon as well. The same issue appears
to exist within the Basic & Digest Auth retry code (though it's much
less likely to surface).

I wound up making the suggested fixes to my local install so I'm
attaching the tiny patch in hopes that someone finds it useful.
msg89297 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2009-06-12 19:39
Looks reasonable to me. I shall test it and commit the patch. Shall try
for tests too.
msg90701 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2009-07-19 02:46
Fixed and committed in revision 74089 and revision 74090.
Should this be backported?
msg90702 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-19 02:50
It's hard to imagine anyone depending on the broken behavior, so I'd
vote yes.
msg90705 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2009-07-19 04:22
backported to release26-maint in the revision 74093
and release31-maint in the revision 74092
Closing this issue.
History
Date User Action Args
2022-04-11 14:56:45adminsetgithub: 49352
2009-07-19 04:22:18orsenthilsetversions: + Python 2.6, Python 3.1
2009-07-19 04:22:03orsenthilsetstatus: open -> closed

messages: + msg90705
2009-07-19 02:52:52orsenthilsetversions: + Python 2.7, - Python 2.6
2009-07-19 02:50:08r.david.murraysetnosy: + r.david.murray
messages: + msg90702
2009-07-19 02:46:17orsenthilsetresolution: fixed
messages: + msg90701
versions: + Python 3.2
2009-06-12 19:39:58orsenthilsetassignee: orsenthil
messages: + msg89297
2009-06-12 19:24:21j_mcneilsetfiles: + urllib2_timeouts.diff

nosy: + j_mcneil
messages: + msg89296

keywords: + patch
2009-04-22 17:23:28ajaksu2setpriority: normal
keywords: + easy
2009-02-13 01:54:29ajaksu2setnosy: + jjlee, orsenthil
stage: test needed
2009-01-31 04:17:01ggenellinasetnosy: + ggenellina
2009-01-29 22:34:59jacquescreate