Skip to content

Commit

Permalink
lsp: Work around openlawlibrary/pygls#433
Browse files Browse the repository at this point in the history
The most recent release of pytest-lsp now surfaces the above issue in
the test suite. So that esbonio is not blocked on a fix, wrap the call
to `shutdown_session` in `asyncio.wait_for` and ignore the timeout error.
  • Loading branch information
alcarney committed Sep 17, 2024
1 parent 1f0c19a commit 2fd2ed6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/esbonio/tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import pathlib
import sys

Expand Down Expand Up @@ -89,4 +90,8 @@ async def client(lsp_client: LanguageClient, uri_for, tmp_path_factory):
yield

# Teardown
await lsp_client.shutdown_session()
try:
await asyncio.wait_for(lsp_client.shutdown_session(), timeout=2.0)
except (asyncio.TimeoutError, TimeoutError):
# HACK: Working around openlawlibrary/pygls#433
print("Gave up waiting for process to exit")
7 changes: 6 additions & 1 deletion lib/esbonio/tests/e2e/test_e2e_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import pathlib
import sys

Expand Down Expand Up @@ -164,7 +165,11 @@ async def pub_client(lsp_client: LanguageClient, uri_for, tmp_path_factory):
yield

# Teardown
await lsp_client.shutdown_session()
try:
await asyncio.wait_for(lsp_client.shutdown_session(), timeout=2.0)
except (asyncio.TimeoutError, TimeoutError):
# HACK: Working around openlawlibrary/pygls#433
print("Gave up waiting for process to exit")


@pytest.mark.asyncio(scope="module")
Expand Down
7 changes: 6 additions & 1 deletion lib/esbonio/tests/server/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import pathlib
import sys

Expand Down Expand Up @@ -40,4 +41,8 @@ async def client(request, uri_for, lsp_client: LanguageClient):
yield

# Teardown
await lsp_client.shutdown_session()
try:
await asyncio.wait_for(lsp_client.shutdown_session(), timeout=2.0)
except (asyncio.TimeoutError, TimeoutError):
# HACK: Working around openlawlibrary/pygls#433
print("Gave up waiting for process to exit")

0 comments on commit 2fd2ed6

Please sign in to comment.