From 87dbe20c23f50dbdb24776aaa6e3e889b4f303c2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 9 Mar 2022 08:53:23 -0500 Subject: [PATCH] Agent: Add human-readable thread name to MonkeyTunnel --- monkey/infection_monkey/tunnel.py | 2 +- monkey/infection_monkey/utils/threading.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/tunnel.py b/monkey/infection_monkey/tunnel.py index 769260d6b..b0f778534 100644 --- a/monkey/infection_monkey/tunnel.py +++ b/monkey/infection_monkey/tunnel.py @@ -126,7 +126,7 @@ class MonkeyTunnel(Thread): self._stopped = Event() self._clients = [] self.local_port = None - super(MonkeyTunnel, self).__init__() + super(MonkeyTunnel, self).__init__(name="MonkeyTunnelThread") self.daemon = True self.l_ips = None self._wait_for_exploited_machines = Event() diff --git a/monkey/infection_monkey/utils/threading.py b/monkey/infection_monkey/utils/threading.py index 80b688759..d1b84523b 100644 --- a/monkey/infection_monkey/utils/threading.py +++ b/monkey/infection_monkey/utils/threading.py @@ -7,7 +7,10 @@ logger = logging.getLogger(__name__) def run_worker_threads( - target: Callable[..., None], name_prefix: str = None, args: Tuple = (), num_workers: int = 2 + target: Callable[..., None], + name_prefix: Optional[str] = None, + args: Tuple = (), + num_workers: int = 2, ): worker_threads = [] counter = run_worker_threads.counters.setdefault(name_prefix, count(start=1))