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:
|
||||
"""Send a HELLO message to the server."""
|
||||
self.logger.debug("[*] Sending HELLO message...")
|
||||
hello_message: bytes = Message.hello(self.mac_address).to_bytes()
|
||||
self.outbound_buffer += hello_message
|
||||
self._send_outbound()
|
||||
hello_message: Message = Message.hello(self.mac_address)
|
||||
self.send(hello_message)
|
||||
|
||||
def close(self) -> None:
|
||||
"""Close the connection and clean up resources."""
|
||||
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.logger.debug("[.] Connection closed.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user