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:
Serhiy Storchaka 2015-04-10 13:24:41 +03:00
parent 842f00e725
commit 7e7a3dba5f
27 changed files with 299 additions and 197 deletions

View file

@ -264,12 +264,13 @@ class Telnet:
def close(self):
"""Close the connection."""
if self.sock:
self.sock.close()
sock = self.sock
self.sock = 0
self.eof = 1
self.iacseq = b''
self.sb = 0
if sock:
sock.close()
def get_socket(self):
"""Return the socket object used internally."""