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