8000 handle cancel correctly · python-lsp/python-lsp-server@c4880f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4880f1

Browse files
author
forozco
committed
handle cancel correctly
1 parent 36e57d5 commit c4880f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pyls/rpc_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
from jsonrpc.exceptions import JSONRPCMethodNotFound, JSONRPCDispatchException, JSONRPCServerError
1010

1111
log = logging.getLogger(__name__)
12-
1312
RESPONSE_CLASS_MAP = {
1413
"1.0": JSONRPC10Response,
1514
"2.0": JSONRPC20Response
1615
}
16+
# as defined in https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md
17+
LSP_CANCEL_CODE = -32800
1718

1819

1920
class MissingMethodException(Exception):
@@ -82,7 +83,8 @@ def cancel(self, request_id):
8283
"""
8384
log.debug('Cancel request %d', request_id)
8485
try:
85-
self._received_requests[request_id].cancel()
86+
self._received_requests[request_id].set_exception(
87+
JSONRPCDispatchException(code=LSP_CANCEL_CODE, message="Request cancelled"))
8688
except KeyError:
8789
log.debug('Received cancel for finished/nonexistent request %d', request_id)
8890

0 commit comments

Comments
 (0)
0