Skip to content
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

Add missing events to gateway client #1288

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions jupyter_server/gateway/gateway_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ async def gateway_request(endpoint: str, **kwargs: ty.Any) -> HTTPResponse:
rhc = RetryableHTTPClient()
try:
response = await rhc.fetch(endpoint, **kwargs)
GatewayClient.instance().emit(
data={STATUS_KEY: SUCCESS_STATUS, STATUS_CODE_KEY: 200, MESSAGE_KEY: "success"}
)
# Trap a set of common exceptions so that we can inform the user that their Gateway url is incorrect
# or the server is not running.
# NOTE: We do this here since this handler is called during the server's startup and subsequent refreshes
Expand Down Expand Up @@ -808,6 +811,15 @@ async def gateway_request(endpoint: str, **kwargs: ty.Any) -> HTTPResponse:
f"The Gateway server specified in the gateway_url '{GatewayClient.instance().url}' doesn't "
f"appear to be valid. Ensure gateway url is valid and the Gateway instance is running.",
) from e
except Exception as e:
GatewayClient.instance().emit(
data={STATUS_KEY: ERROR_STATUS, STATUS_CODE_KEY: 505, MESSAGE_KEY: str(e)}
)
logging.getLogger("ServerApp").error(
f"Exception while trying to launch kernel via Gateway URL {GatewayClient.instance().url} , {e}",
e,
)
raise e

if GatewayClient.instance().accept_cookies:
# Update cookies on GatewayClient from server if configured.
Expand Down