1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #27368 -- Modifed BaseEmailBackend.__enter__() to close the connection if an exception occurs.

Fixes unclosed socket ResourceWarning in mail test.

Thanks Claude Paroz for the review.
This commit is contained in:
Jon Dufresne
2016-10-21 05:59:07 -07:00
committed by GitHub
parent 1f5b69917d
commit 9b9c8c4a81
2 changed files with 16 additions and 17 deletions

View File

@@ -40,7 +40,11 @@ class BaseEmailBackend(object):
pass
def __enter__(self):
self.open()
try:
self.open()
except Exception:
self.close()
raise
return self
def __exit__(self, exc_type, exc_value, traceback):