Register for signals only when running in main thread (#1087)

This commit is contained in:
Abhinav Singh 2022-02-11 00:18:40 +05:30 committed by GitHub
parent dc15dc1075
commit 0629fc43e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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: