mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #23865: close() methods in multiple modules now are idempotent and more
robust at shutdown. If needs to release multiple resources, they are released even if errors are occured.
This commit is contained in:
commit
2116b12da5
27 changed files with 315 additions and 209 deletions
|
@ -880,12 +880,16 @@ class SMTP:
|
|||
|
||||
def close(self):
|
||||
"""Close the connection to the SMTP server."""
|
||||
if self.file:
|
||||
self.file.close()
|
||||
self.file = None
|
||||
if self.sock:
|
||||
self.sock.close()
|
||||
self.sock = None
|
||||
try:
|
||||
file = self.file
|
||||
self.file = None
|
||||
if file:
|
||||
file.close()
|
||||
finally:
|
||||
sock = self.sock
|
||||
self.sock = None
|
||||
if sock:
|
||||
sock.close()
|
||||
|
||||
def quit(self):
|
||||
"""Terminate the SMTP session."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue