Skip to content

Commit 59fd33c

Browse files
authored
Pass on ConnectionResetError in _StreamHandlerWrapper (#684)
1 parent 19b10c4 commit 59fd33c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pyls/python_ls.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Copyright 2017 Palantir Technologies, Inc.
2+
from functools import partial
23
import logging
4+
import os
35
import socketserver
46
import threading
5-
from functools import partial
67

78
from pyls_jsonrpc.dispatchers import MethodDispatcher
89
from pyls_jsonrpc.endpoint import Endpoint
@@ -33,7 +34,16 @@ def setup(self):
3334
self.delegate = self.DELEGATE_CLASS(self.rfile, self.wfile)
3435

3536
def handle(self):
36-
self.delegate.start()
37+
try:
38+
self.delegate.start()
39+
except OSError as e:
40+
if os.name == 'nt':
41+
# Catch and pass on ConnectionResetError when parent process
42+
# dies
43+
# pylint: disable=no-member, undefined-variable
44+
if isinstance(e, WindowsError) and e.winerror == 10054:
45+
pass
46+
3747
# pylint: disable=no-member
3848
self.SHUTDOWN_CALL()
3949

@@ -202,7 +212,7 @@ def m_initialize(self, processId=None, rootUri=None, rootPath=None, initializati
202212
def watch_parent_process(pid):
203213
# exit when the given pid is not alive
204214
if not _utils.is_process_alive(pid):
205-
log.info("parent process %s is not alive", pid)
215+
log.info("parent process %s is not alive, exiting!", pid)
206216
self.m_exit()
207217
else:
208218
threading.Timer(PARENT_PROCESS_WATCH_INTERVAL, watch_parent_process, args=[pid]).start()

0 commit comments

Comments
 (0)