Skip to content

Commit f759af2

Browse files
andfoyccordoba12
authored andcommitted
Enable parent process checking for TCP server (#642)
1 parent a7b2c62 commit f759af2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pyls/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ def main():
5555
_configure_logger(args.verbose, args.log_config, args.log_file)
5656

5757
if args.tcp:
58-
start_tcp_lang_server(args.host, args.port, PythonLanguageServer)
58+
start_tcp_lang_server(args.host, args.port, args.check_parent_process,
59+
PythonLanguageServer)
5960
else:
6061
stdin, stdout = _binary_stdio()
61-
start_io_lang_server(stdin, stdout, args.check_parent_process, PythonLanguageServer)
62+
start_io_lang_server(stdin, stdout, args.check_parent_process,
63+
PythonLanguageServer)
6264

6365

6466
def _binary_stdio():

pyls/python_ls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import socketserver
44
import threading
5+
from functools import partial
56

67
from pyls_jsonrpc.dispatchers import MethodDispatcher
78
from pyls_jsonrpc.endpoint import Endpoint
@@ -35,15 +36,16 @@ def handle(self):
3536
self.delegate.start()
3637

3738

38-
def start_tcp_lang_server(bind_addr, port, handler_class):
39+
def start_tcp_lang_server(bind_addr, port, check_parent_process, handler_class):
3940
if not issubclass(handler_class, PythonLanguageServer):
4041
raise ValueError('Handler class must be an instance of PythonLanguageServer')
4142

4243
# Construct a custom wrapper class around the user's handler_class
4344
wrapper_class = type(
4445
handler_class.__name__ + 'Handler',
4546
(_StreamHandlerWrapper,),
46-
{'DELEGATE_CLASS': handler_class}
47+
{'DELEGATE_CLASS': partial(handler_class,
48+
check_parent_process=check_parent_process)}
4749
)
4850

4951
server = socketserver.TCPServer((bind_addr, port), wrapper_class)

0 commit comments

Comments
 (0)