Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib2.Request constructor has no timeout parameter #46702

Closed
jjlee mannequin opened this issue Mar 21, 2008 · 5 comments
Closed

urllib2.Request constructor has no timeout parameter #46702

jjlee mannequin opened this issue Mar 21, 2008 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@jjlee
Copy link
Mannequin

jjlee mannequin commented Mar 21, 2008

BPO 2450
Nosy @facundobatista

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/facundobatista'
closed_at = <Date 2008-03-22.00:50:47.745>
created_at = <Date 2008-03-21.22:58:08.281>
labels = ['library']
title = 'urllib2.Request constructor has no timeout parameter'
updated_at = <Date 2008-03-22.02:28:24.516>
user = 'https://bugs.python.org/jjlee'

bugs.python.org fields:

activity = <Date 2008-03-22.02:28:24.516>
actor = 'jjlee'
assignee = 'facundobatista'
closed = True
closed_date = <Date 2008-03-22.00:50:47.745>
closer = 'facundobatista'
components = ['Library (Lib)']
creation = <Date 2008-03-21.22:58:08.281>
creator = 'jjlee'
dependencies = []
files = []
hgrepos = []
issue_num = 2450
keywords = []
message_count = 5.0
messages = ['64291', '64304', '64307', '64308', '64311']
nosy_count = 2.0
nosy_names = ['facundobatista', 'jjlee']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue2450'
versions = ['Python 2.6']

@jjlee
Copy link
Mannequin Author

jjlee mannequin commented Mar 21, 2008

r55792 added timeout support to urllib2. A timeout parameter was added
to urllib2.OpenerDirector.open(), but there is no corresponding Request
constructor parameter. timeout is unique in that respect. Instead,
OpenerDirector.open() sets req.timeout on request instances. The
parameter "timeout" should behave in the same way as existing parameter
"data".

@jjlee jjlee mannequin added the stdlib Python modules in the Lib dir label Mar 21, 2008
@facundobatista facundobatista self-assigned this Mar 21, 2008
@facundobatista
Copy link
Member

The argument timeout can not have the same semantics than data, see the
following cases:

  • r = Request(url)

  • urlopen(r, data="foo")

  • data is "foo"

  • r = Request(url, data="foo")

  • urlopen(r)

  • data is "foo"

  • r = Request(url, data="foo")

  • urlopen(r, data="bar")

  • data is "bar"

So, what would happen if you put timeout in Request:

  • r = Request(url, timeout=3)

  • urlopen(r, timeout=10)

  • here, the final timeout can be 10, no problem!

  • r = Request(url, timeout=3)

  • urlopen(r)

  • Oops!

In this last one, which the final timeout should be? None, as you passed
that to urlopen()? Or the original 3 from the Request?

With data you can do it, because None has no meaning, so only you
replace the Request value if actually you passed something in urlopen().
But for timeout, None *has* a meaning...

@jjlee
Copy link
Mannequin Author

jjlee mannequin commented Mar 22, 2008

This should be solved by introducing a "not set" value other than None.

@facundobatista
Copy link
Member

As I wrote in the other bug that you opened (bpo-2451), introducing this
will complicate the usage and semantics of what is already established
and working.

@jjlee
Copy link
Mannequin Author

jjlee mannequin commented Mar 22, 2008

I don't buy the "API complication" argument.

I might accept an argument that the timeout isn't really anything to do
with the request, so I won't bother to continue with this bug report.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant