Skip to content

Commit

Permalink
handle cancel correctly (#289)
Browse files Browse the repository at this point in the history
* handle cancel correctly

* move paren
  • Loading branch information
ferozco authored Mar 15, 2018
1 parent 7fda2ab commit f57323e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyls/rpc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from jsonrpc.exceptions import JSONRPCMethodNotFound, JSONRPCDispatchException, JSONRPCServerError

log = logging.getLogger(__name__)

RESPONSE_CLASS_MAP = {
"1.0": JSONRPC10Response,
"2.0": JSONRPC20Response
}
# as defined in https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md
LSP_CANCEL_CODE = -32800


class MissingMethodException(Exception):
Expand Down Expand Up @@ -83,7 +84,9 @@ def cancel(self, request_id):
"""
log.debug('Cancel request %d', request_id)
try:
self._received_requests[request_id].cancel()
self._received_requests[request_id].set_exception(
JSONRPCDispatchException(code=LSP_CANCEL_CODE, message="Request cancelled")
)
except KeyError:
log.debug('Received cancel for finished/nonexistent request %d', request_id)

Expand Down

0 comments on commit f57323e

Please sign in to comment.