Send the quit message and close the socket. See `Connection.close() `_ in the specification. :raise Error: If the connection is already closed.
(self)
| 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): |
no test coverage detected