feat!: Add timeout parameter to SendGrid API clients#1125
Open
pellepim wants to merge 1 commit intosendgrid:mainfrom
Open
feat!: Add timeout parameter to SendGrid API clients#1125pellepim wants to merge 1 commit intosendgrid:mainfrom
pellepim wants to merge 1 commit intosendgrid:mainfrom
Conversation
Default to a 30 second HTTP timeout to prevent hung processes. The timeout is passed through to python_http_client which already supports it. Callers can override or disable (via None) as needed. Timeouts via send() raise SendGridTimeoutError for clean handling.
1bfb2ed to
5c889c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
HTTP requests made by this library (e.g., to send emails via the APIs) have no timeout by default. If a network issue causes a request to hang, the calling process blocks indefinitely.
This PR adds a timeout parameter (defaulting to 30 seconds) to
SendGridAPIClientandTwilioEmailAPIClient. The underlyingpython_http_clientalready supports this. Callers can override the default or disable it by passingtimeout=None.Technically, this is a breaking change. Code that previously hung silently will now raise the new
SendGridTimeoutErrorexception aftertimeoutseconds. Anyone relying on infinite wait (intentionally or not) will see new exceptions.That said, it's hard to argue the previous behavior was correct. A process hanging forever isn't really "working." But strictly by semver rules, changing the default from no timeout to 30 seconds is a breaking change since it alters existing behavior.
Checklist
and my PR follows them
If you have questions, please file a support ticket.