Skip to content

Commit

Permalink
Pass on ConnectionResetError in _StreamHandlerWrapper (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored Oct 28, 2019
1 parent 19b10c4 commit 59fd33c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pyls/python_ls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright 2017 Palantir Technologies, Inc.
from functools import partial
import logging
import os
import socketserver
import threading
from functools import partial

from pyls_jsonrpc.dispatchers import MethodDispatcher
from pyls_jsonrpc.endpoint import Endpoint
Expand Down Expand Up @@ -33,7 +34,16 @@ def setup(self):
self.delegate = self.DELEGATE_CLASS(self.rfile, self.wfile)

def handle(self):
self.delegate.start()
try:
self.delegate.start()
except OSError as e:
if os.name == 'nt':
# Catch and pass on ConnectionResetError when parent process
# dies
# pylint: disable=no-member, undefined-variable
if isinstance(e, WindowsError) and e.winerror == 10054:
pass

# pylint: disable=no-member
self.SHUTDOWN_CALL()

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

0 comments on commit 59fd33c

Please sign in to comment.