Preserve default total timeout when other timeout is changed in ClientSession.__init__() #7268
Unanswered
wombatonfire
asked this question in
Ideas
Replies: 1 comment 1 reply
-
I think changing the default for |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is a default total timeout
DEFAULT_TIMEOUT: Final[ClientTimeout] = ClientTimeout(total=5 * 60)
used by the
ClientSession
when no explicit session-level timeout is provided:This is, definitely, a good thing, you don't want to wait forever in the worst-case scenario.
The problem is, it's very easy to unintentionally reset this default:
Because of the way how ClientSession is initialized
when you change some other - more specific - timeout and do not explicitly provide the value for the total timeout, the default for the total is not preserved and is reset to
None
.It looks to me like an undesirable side-effect and something you, probably, do not expect. Documentation also does not cover this behavior.
I think the better approach would be to merge the default total timeout value, when it's not being overridden, with whatever more specific timeout is passed on
ClientSession.__init__()
. Something that was done in earlier versions for the now deprecatedread_timeout
andconn_timeout
:self._timeout = attr.evolve(self._timeout, connect=conn_timeout)
If this makes sense, I'm happy to provide the patch.
Beta Was this translation helpful? Give feedback.
All reactions