-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make websocket server to send ping frame to client #459
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,30 @@ async def test_start_unknown(known_unknown_server, handlers, jsonrpc_init_msg): | |
|
||
assert not manager.sessions.get(ws_handler.language_server) | ||
assert_status_set(handler, {"not_started"}) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_ping(handlers): | ||
"""see https://github.com/krassowski/jupyterlab-lsp/issues/458""" | ||
a_server = "pyls" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just do not think it is needed to run this check for all language servers (just wanted to have something to pass to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, yeah, maybe we need a real pygls mock server at some point :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fine with bringing pygls as a mock dependency in the future. |
||
|
||
handler, ws_handler = handlers | ||
manager = handler.manager | ||
|
||
manager.initialize() | ||
|
||
assert ws_handler.ping_interval > 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tests are looking good |
||
# the default ping interval is 30 seconds, too long for a test | ||
ws_handler.settings["ws_ping_interval"] = 0.1 | ||
assert ws_handler.ping_interval == 0.1 | ||
|
||
assert ws_handler._ping_sent is False | ||
|
||
ws_handler.open(a_server) | ||
|
||
assert ws_handler.ping_callback is not None and ws_handler.ping_callback.is_running | ||
await asyncio.sleep(ws_handler.ping_interval * 3) | ||
|
||
assert ws_handler._ping_sent is True | ||
|
||
ws_handler.on_close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good catch. might we even want to
super.open
first, before any overloaded behavior?