Skip to content

Commit

Permalink
Do not start shutdown sequence on TCP when not checking parent process (
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy authored Jun 22, 2020
1 parent 10cd98c commit c57bf89
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pyls/python_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,21 @@ 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(
handler_class.__name__ + 'Handler',
(_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)
Expand Down

0 comments on commit c57bf89

Please sign in to comment.