MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / close

Method close

pymysql/connections.py:427–446  ·  view source on GitHub ↗

Send the quit message and close the socket. See `Connection.close() `_ in the specification. :raise Error: If the connection is already closed.

(self)

Source from the content-addressed store, hash-verified

425 return ctx
426
427 def close(self):
428 """
429 Send the quit message and close the socket.
430
431 See `Connection.close() <https://www.python.org/dev/peps/pep-0249/#Connection.close>`_
432 in the specification.
433
434 :raise Error: If the connection is already closed.
435 """
436 if self._closed:
437 raise err.Error("Already closed")
438 self._closed = True
439 if self._sock is None:
440 return
441 send_data = struct.pack("<iB", 1, COMMAND.COM_QUIT)
442 try:
443 with contextlib.suppress(Exception):
444 self._write_bytes(send_data)
445 finally:
446 self._force_close()
447
448 @property
449 def open(self):

Callers 3

__exit__Method · 0.95
_force_closeMethod · 0.45
connectMethod · 0.45

Calls 2

_write_bytesMethod · 0.95
_force_closeMethod · 0.95

Tested by

no test coverage detected