@@ -52,20 +52,21 @@ def start_tcp_lang_server(bind_addr, port, check_parent_process, handler_class):
5252 if not issubclass (handler_class , PythonLanguageServer ):
5353 raise ValueError ('Handler class must be an instance of PythonLanguageServer' )
5454
55- def shutdown_server (* args ):
55+ def shutdown_server (check_parent_process , * args ):
5656 # pylint: disable=unused-argument
57- log .debug ('Shutting down server' )
58- # Shutdown call must be done on a thread, to prevent deadlocks
59- stop_thread = threading .Thread (target = server .shutdown )
60- stop_thread .start ()
57+ if check_parent_process :
58+ log .debug ('Shutting down server' )
59+ # Shutdown call must be done on a thread, to prevent deadlocks
60+ stop_thread = threading .Thread (target = server .shutdown )
61+ stop_thread .start ()
6162
6263 # Construct a custom wrapper class around the user's handler_class
6364 wrapper_class = type (
6465 handler_class .__name__ + 'Handler' ,
6566 (_StreamHandlerWrapper ,),
6667 {'DELEGATE_CLASS' : partial (handler_class ,
6768 check_parent_process = check_parent_process ),
68- 'SHUTDOWN_CALL' : shutdown_server }
69+ 'SHUTDOWN_CALL' : partial ( shutdown_server , check_parent_process ) }
6970 )
7071
7172 server = socketserver .TCPServer ((bind_addr , port ), wrapper_class , bind_and_activate = False )
0 commit comments