Skip to content

Commit

Permalink
pytest-lsp: Cancel requests and kill server process on error
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Nov 4, 2024
1 parent ee179de commit 5941caa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/pytest-lsp/pytest_lsp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ def report_server_error(
tb = "".join(traceback.format_exc())

message = f"{source.__name__}: {error}\n{tb}" # type: ignore
for id_, fut in self.protocol._request_futures.items():
if not fut.done():
fut.set_exception(RuntimeError(message))
logger.debug("Cancelled pending request '%s': %s", id_, message)

loop = asyncio.get_running_loop()
loop.call_soon(cancel_all_tasks, message)

if self._stop_event:
self._stop_event.set()
if self._server:
self._server.terminate()

def get_configuration(
self, *, section: str | None = None, scope_uri: str | None = None
Expand Down

0 comments on commit 5941caa

Please sign in to comment.