HTTP requests to SendGrid could hang, as SendGridAPIClient has no time out defined in case of a network anomaly.
This is a bit difficult to reproduce, as it could be caused by a network anomaly (Not necessarily SendGrid's issue).
When a network anomaly occurred, it is possible for API calls to SendGrid to hang indefinitely.
SendGridAPIClient creates a client, it does not allow a timeout to be passed in.SendGridAPIClient to override SendGridAPIClient.client or to have an outer wrapper to control timeout.Expected Behavior
Either a reasonable timeout is set, or a timeout option should be allowed when creating a SendGridAPIClient.
Actual
None is available.
Relevant Link:
SendGridAPIClient: https://github.com/sendgrid/sendgrid-python/blob/265b9848834f3a2ff2c3d92fb1b711cd7f33f438/sendgrid/sendgrid.py#L75Great catch! I've tagged this appropriately and the fix should happen on the v4 branch here..
With Best Regards,
Elmer
It seems it is still not fixed in the last versions, am I right?
It did not @erdnaxeli, but thanks for the comment. Your comment helps us move this up the ladder in our backlog. Thanks!
We've had the same problem recently, for now I've fixed it with:
sendgrid_client = sendgrid.SendGridAPIClient()
sendgrid_client.client.timeout = 10
Hopefully this will be fixed soon, being able to set the timeout when initializing the client would be great.
Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!
I'm also having this issue on python 3.7 and sendgrid==6.6.0.
Most helpful comment
We've had the same problem recently, for now I've fixed it with:
Hopefully this will be fixed soon, being able to set the timeout when initializing the client would be great.