-
Notifications
You must be signed in to change notification settings - Fork 48
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
Operation-level timeout #207
Comments
Thanks for reporting! Current expected behaviour is that two I agree this doesn't work well for the case where the connect timeout should be different than the default. I'll have a look but I think the suggested change is reasonable, probably I can proceed with that 👍 |
Hi Cole, thanks for the great lib! I'm happy to contribute and implement this change. I haven't checked other methods, only |
Ok, so This required changing the signature of The timeout argument was also removed from If this makes sense, I suppose some tests should be added? |
Didn't realize the pull request was created in the wrong repository/branch. |
Is your feature request related to a problem? Please describe.
It may be reasonable to have different timeouts for different operations during the SMTP session. Specifically, you may want
connect()
to fail fast when provided server details were clearly wrong, but givesend_message()
some more time to wait for a response from the server.Based on the
SMTP
class documentation you may think that there is a "global" client timeout (timeout=
inSMTP.__init__()
), which can be overridden for a specific operation (method) using atimeout
keyword argument. The problem is that, when you do it, you do not simply override the timeout for this operation, but you change the "global" client timeout. The new timeout value is saved asself.timeout
and will be used for all subsequent operations.This is, probably, not what you would expect, and requires an explicit reset of the timeout in the user code.
Describe the solution you'd like
I think, when
timeout
is overridden on the operation level, it should not be processed in_update_settings_from_kwargs()
along with other keyword arguments and it should not overwrite the client-level value. When this specific operation is completed, all subsequent operations should continue using the client-level timeout, and not the operation-level override.Describe alternatives you've considered
The alternative is to explicitly reset the client-level timeout to the value used before the override was specified. This is what I do now.
The text was updated successfully, but these errors were encountered: