@@ -52,20 +52,21 @@ def start_tcp_lang_server(bind_addr, port, check_parent_process, handler_class):
52
52
if not issubclass (handler_class , PythonLanguageServer ):
53
53
raise ValueError ('Handler class must be an instance of PythonLanguageServer' )
54
54
55
- def shutdown_server (* args ):
55
+ def shutdown_server (check_parent_process , * args ):
56
56
# 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 ()
61
62
62
63
# Construct a custom wrapper class around the user's handler_class
63
64
wrapper_class = type (
64
65
handler_class .__name__ + 'Handler' ,
65
66
(_StreamHandlerWrapper ,),
66
67
{'DELEGATE_CLASS' : partial (handler_class ,
67
68
check_parent_process = check_parent_process ),
68
- 'SHUTDOWN_CALL' : shutdown_server }
69
+ 'SHUTDOWN_CALL' : partial ( shutdown_server , check_parent_process ) }
69
70
)
70
71
71
72
server = socketserver .TCPServer ((bind_addr , port ), wrapper_class , bind_and_activate = False )
0 commit comments