feat(connector.py): handle self.selector.unregister exceptions in Connector.close()
This commit is contained in:
@@ -106,14 +106,16 @@ class Connector:
|
|||||||
def send_hello(self) -> None:
|
def send_hello(self) -> None:
|
||||||
"""Send a HELLO message to the server."""
|
"""Send a HELLO message to the server."""
|
||||||
self.logger.debug("[*] Sending HELLO message...")
|
self.logger.debug("[*] Sending HELLO message...")
|
||||||
hello_message: bytes = Message.hello(self.mac_address).to_bytes()
|
hello_message: Message = Message.hello(self.mac_address)
|
||||||
self.outbound_buffer += hello_message
|
self.send(hello_message)
|
||||||
self._send_outbound()
|
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
"""Close the connection and clean up resources."""
|
"""Close the connection and clean up resources."""
|
||||||
self.logger.debug("[*] Closing connection...")
|
self.logger.debug("[*] Closing connection...")
|
||||||
self.selector.unregister(self.socket)
|
try:
|
||||||
|
self.selector.unregister(self.socket)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"[!] Error unregistering socket: {e}")
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.logger.debug("[.] Connection closed.")
|
self.logger.debug("[.] Connection closed.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user