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

Method close

pymysql/connections.py:422–441  ·  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

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