Agent: Give TCPConnectionHandler thread a name

This commit is contained in:
Kekoa Kaaikala 2022-09-02 15:05:19 +00:00
parent 62e4fb89bb
commit b179f602c4
1 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import socket import socket
from ipaddress import IPv4Address from ipaddress import IPv4Address
from threading import Thread from threading import Event, Thread
from typing import Callable from typing import Callable
PROXY_TIMEOUT = 2.5 PROXY_TIMEOUT = 2.5
@ -18,9 +18,8 @@ class TCPConnectionHandler(Thread):
self.local_port = local_port self.local_port = local_port
self.local_host = local_host self.local_host = local_host
self._client_connected = client_connected self._client_connected = client_connected
super().__init__() super().__init__(name="TCPConnectionHandler", daemon=True)
self.daemon = True self._stopped = Event()
self._stopped = False
def run(self): def run(self):
l_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) l_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@ -40,7 +39,7 @@ class TCPConnectionHandler(Thread):
l_socket.close() l_socket.close()
def stop(self): def stop(self):
self._stopped = True self._stopped.set()
def notify_client_connected(self, callback: Callable[[socket.socket, IPv4Address], None]): def notify_client_connected(self, callback: Callable[[socket.socket, IPv4Address], None]):
""" """