From 0629fc43e94ff39ccadd6db3bb4984bc92a3aa09 Mon Sep 17 00:00:00 2001 From: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> Date: Fri, 11 Feb 2022 00:18:40 +0530 Subject: [PATCH] Register for signals only when running in main thread (#1087) --- proxy/proxy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.py b/proxy/proxy.py index 3ea2f4a5..b9b602d6 100644 --- a/proxy/proxy.py +++ b/proxy/proxy.py @@ -14,6 +14,7 @@ import time import pprint import signal import logging +import threading from typing import TYPE_CHECKING, Any, List, Optional, cast from .core.ssh import SshTunnelListener, SshHttpProtocolHandler @@ -255,7 +256,8 @@ class Proxy: ('', self.flags.tunnel_remote_port), ) # TODO: May be close listener fd as we don't need it now - self._register_signals() + if threading.current_thread() == threading.main_thread(): + self._register_signals() def shutdown(self) -> None: if self.flags.enable_ssh_tunnel: