From c57bf8940411676ccc82c74e8a32227289cda30f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Andr=C3=A9s=20Margffoy=20Tuay?= Date: Mon, 22 Jun 2020 13:35:41 -0500 Subject: [PATCH] Do not start shutdown sequence on TCP when not checking parent process (#820) --- pyls/python_ls.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyls/python_ls.py b/pyls/python_ls.py index 8d6c5f0d..754cee99 100644 --- a/pyls/python_ls.py +++ b/pyls/python_ls.py @@ -52,12 +52,13 @@ def start_tcp_lang_server(bind_addr, port, check_parent_process, handler_class): if not issubclass(handler_class, PythonLanguageServer): raise ValueError('Handler class must be an instance of PythonLanguageServer') - def shutdown_server(*args): + def shutdown_server(check_parent_process, *args): # pylint: disable=unused-argument - log.debug('Shutting down server') - # Shutdown call must be done on a thread, to prevent deadlocks - stop_thread = threading.Thread(target=server.shutdown) - stop_thread.start() + if check_parent_process: + log.debug('Shutting down server') + # Shutdown call must be done on a thread, to prevent deadlocks + stop_thread = threading.Thread(target=server.shutdown) + stop_thread.start() # Construct a custom wrapper class around the user's handler_class wrapper_class = type( @@ -65,7 +66,7 @@ def shutdown_server(*args): (_StreamHandlerWrapper,), {'DELEGATE_CLASS': partial(handler_class, check_parent_process=check_parent_process), - 'SHUTDOWN_CALL': shutdown_server} + 'SHUTDOWN_CALL': partial(shutdown_server, check_parent_process)} ) server = socketserver.TCPServer((bind_addr, port), wrapper_class, bind_and_activate=False)