BradWhittington/django-mailgun — pull request #12 by Sapphire64 (2014-06-13 11:33:08+00:00)
Title: Code clean up and timeout support

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)