-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Client request timeout parameters are inconsistent #1861
Labels
Comments
ykshatroff
added a commit
to ykshatroff/aiohttp
that referenced
this issue
Apr 30, 2017
…istent Use sentinel (instead of None) for checking the arguments passed. aiohttp/client.py: * ClientSession.__init__(): * set the `read_timeout` argument default value to `sentinel` * if it is equal to `sentinel` during the call, set it to the value of `DEFAULT_TIMEOUT` * ClientSession._request(): * set the `timeout` argument default value to `sentinel` * if it is equal to `sentinel` during the call, set it to the value of `self.read_timeout` Update documentation to match the consistent usage of timeouts. Update tests (excluding the confusing `timeout=None` argument usage).
ykshatroff
added a commit
to ykshatroff/aiohttp
that referenced
this issue
Apr 30, 2017
…istent Use sentinel (instead of None) for checking the arguments passed. aiohttp/client.py: * ClientSession.__init__(): * set the `read_timeout` argument default value to `sentinel` * if it is equal to `sentinel` during the call, set it to the value of `DEFAULT_TIMEOUT` * ClientSession._request(): * set the `timeout` argument default value to `sentinel` * if it is equal to `sentinel` during the call, set it to the value of `self.read_timeout` Update documentation to match the consistent usage of timeouts. Update tests (excluding the confusing `timeout=None` argument usage).
5 tasks
fafhrd91
added a commit
that referenced
this issue
May 2, 2017
fix Issue #1861: Client request timeout parameters are inconsistent
thanks for PR! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Long story short
The behavior of the
read_timeout
argument ofClientSession
constructor and thetimeout
argument ofClientSession.request()
method is inconsistent and prevents use ofClientSession.read_timeout
in requests by default.Expected behaviour
Passing
read_timeout
toClientSession
constructor makes the passed value the default timeout for every session request (i.e. when notimeout
argument is passed tosession.request()
),as well as passing
timeout=None
explicitly tosession.request()
disables the timeout.Actual behaviour
In the docs, it's stated that
timeout=None
passed tosession.request()
disables the timeout. Instead, it forces the use of session's default timeout.Moreover, the session's
read_timeout
is effectively unused by default, instead theDEFAULT_TIMEOUT
(5*60) is used. To enable the session'sread_timeout
for requests, we must passtimeout=None
explicitly to every request, which in turn contradicts to the meaning ofNone
as completely disabling the timeout.This behavior is very inconvenient and error-prone, allowing for the situation where we are unexpectedly left without any timeout (when we don't pass a
read_timeout
toClientSession
and pass atimeout=None
toreqeust()
in order to get theread_timeout
into effect).Steps to reproduce
In this code, the effective timeout is not 0.01 but 5*60:
In this code, the effective timeout is 0.01 instead of no timeout:
In this code, there is effectively no timeout at all, though one could think naively that omitting
read_timeout
in session constructor effects in some default timeout being used:Your environment
This issue is relevant to any
aiohttp==2.0.7
setup.The text was updated successfully, but these errors were encountered: