MCPcopy
hub / github.com/PyMySQL/PyMySQL / close

Method close

pymysql/connections.py:421–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

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