This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
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.
Hello
We had problems with blocking processes in our project. Emails were sent using celery, and sometimes all workers become unavailable after sending bunch of emails. I tried some basic testing with requests library and it seems like mailgun got no real timeout, so if connection exists it can last for a while. I've added an option to explicitly specify timeout period using requests' timeout kwarg. It can be None or float value. If connection will not be closed after some reasonable time this option will kill it. I think this option should be helpful, and yet it is optional.
Also I've some basic PEP8 and clean up of the code and project, hope you will enjoy it.
Logging in celery:
[2014-06-13 07:23:09,034: INFO/Worker-3] Starting new HTTPS connection (1): api.mailgun.net
[2014-06-13 07:23:09,522: WARNING/Worker-3] HTTPSConnectionPool(host='api.mailgun.net', port=443): Request timed out. (timeout=0.0001)