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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user