mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +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
|
@ -261,12 +261,13 @@ class Telnet:
|
|||
|
||||
def close(self):
|
||||
"""Close the connection."""
|
||||
if self.sock:
|
||||
self.sock.close()
|
||||
self.sock = 0
|
||||
self.eof = 1
|
||||
sock = self.sock
|
||||
self.sock = None
|
||||
self.eof = True
|
||||
self.iacseq = b''
|
||||
self.sb = 0
|
||||
if sock:
|
||||
sock.close()
|
||||
|
||||
def get_socket(self):
|
||||
"""Return the socket object used internally."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue