From 8d162afd48fd966f53ff2d7224feebeddce2849c Mon Sep 17 00:00:00 2001 From: smathot Date: Mon, 4 May 2020 08:13:30 +0200 Subject: [PATCH] LspEndpoint: check server exit before parsing message --- pylspclient/lsp_endpoint.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pylspclient/lsp_endpoint.py b/pylspclient/lsp_endpoint.py index f3b871b..8364d6f 100644 --- a/pylspclient/lsp_endpoint.py +++ b/pylspclient/lsp_endpoint.py @@ -32,16 +32,15 @@ class LspEndpoint(threading.Thread): while not self.shutdown_flag: try: jsonrpc_message = self.json_rpc_endpoint.recv_response() + if jsonrpc_message is None: + print("server quit") + break method = jsonrpc_message.get("method") result = jsonrpc_message.get("result") error = jsonrpc_message.get("error") rpc_id = jsonrpc_message.get("id") params = jsonrpc_message.get("params") - if jsonrpc_message is None: - print("server quit") - break - if method: if rpc_id: # a call for method