Skip to content

Commit

Permalink
Remove parameters from async handler (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Mar 28, 2018
1 parent aaa362c commit 95d7535
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyls/jsonrpc/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _handle_notification(self, method, params):

if callable(handler_result):
log.debug("Executing async notification handler %s", handler_result)
notification_future = self._executor_service.submit(handler_result, params)
notification_future = self._executor_service.submit(handler_result)
notification_future.add_done_callback(self._notification_callback(method, params))

@staticmethod
Expand Down Expand Up @@ -183,7 +183,7 @@ def _handle_request(self, msg_id, method, params):

if callable(handler_result):
log.debug("Executing async request handler %s", handler_result)
request_future = self._executor_service.submit(handler_result, params)
request_future = self._executor_service.submit(handler_result)
self._client_request_futures[msg_id] = request_future
request_future.add_done_callback(self._request_callback(msg_id))
else:
Expand Down
12 changes: 4 additions & 8 deletions test/jsonrpc/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def test_consume_notification_method_not_found(endpoint):


def test_consume_async_notification_error(endpoint, dispatcher):
def _async_handler(params):
assert params == {'key': 'value'}
def _async_handler():
raise ValueError()
handler = mock.Mock(return_value=_async_handler)
dispatcher['methodName'] = handler
Expand Down Expand Up @@ -189,8 +188,7 @@ def test_consume_request(endpoint, consumer, dispatcher):


def test_consume_async_request(endpoint, consumer, dispatcher):
def _async_handler(params):
assert params == {'key': 'value'}
def _async_handler():
return 1234
handler = mock.Mock(return_value=_async_handler)
dispatcher['methodName'] = handler
Expand All @@ -216,8 +214,7 @@ def _async_handler(params):
(exceptions.JsonRpcMethodNotFound, exceptions.JsonRpcMethodNotFound()),
])
def test_consume_async_request_error(exc_type, error, endpoint, consumer, dispatcher):
def _async_handler(params):
assert params == {'key': 'value'}
def _async_handler():
raise exc_type()
handler = mock.Mock(return_value=_async_handler)
dispatcher['methodName'] = handler
Expand Down Expand Up @@ -264,8 +261,7 @@ def test_consume_request_error(exc_type, error, endpoint, consumer, dispatcher):


def test_consume_request_cancel(endpoint, dispatcher):
def async_handler(params):
assert params == {'key': 'value'}
def async_handler():
time.sleep(3)
handler = mock.Mock(return_value=async_handler)
dispatcher['methodName'] = handler
Expand Down

0 comments on commit 95d7535

Please sign in to comment.