MCPcopy Index your code
hub / github.com/python/cpython / close

Method close

Lib/poplib.py:296–317  ·  view source on GitHub ↗

Close the connection without assuming anything about it.

(self)

Source from the content-addressed store, hash-verified

294 return resp
295
296 def close(self):
297 """Close the connection without assuming anything about it."""
298 try:
299 file = self.file
300 self.file = None
301 if file is not None:
302 file.close()
303 finally:
304 sock = self.sock
305 self.sock = None
306 if sock is not None:
307 try:
308 sock.shutdown(socket.SHUT_RDWR)
309 except OSError as exc:
310 # The server might already have closed the connection.
311 # On Windows, this may result in WSAEINVAL (error 10022):
312 # An invalid operation was attempted.
313 if (exc.errno != errno.ENOTCONN
314 and getattr(exc, 'winerror', 0) != 10022):
315 raise
316 finally:
317 sock.close()
318
319 #__del__ = quit
320

Callers 4

quitMethod · 0.95
testTimeoutDefaultMethod · 0.95
testTimeoutNoneMethod · 0.95
testTimeoutValueMethod · 0.95

Calls 1

shutdownMethod · 0.45

Tested by 3

testTimeoutDefaultMethod · 0.76
testTimeoutNoneMethod · 0.76
testTimeoutValueMethod · 0.76