From 8ccb198b3fffaa9880257b8ecc0919934b9a456e Mon Sep 17 00:00:00 2001 From: Jonathan Sick Date: Fri, 22 Mar 2024 13:38:44 -0400 Subject: [PATCH] Identify httpx ReadTimeout errors from execution Specifically identify when the JupyterLab /execution request fails because of a timeout. --- src/noteburst/jupyterclient/jupyterlab.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/noteburst/jupyterclient/jupyterlab.py b/src/noteburst/jupyterclient/jupyterlab.py index 54a447f..3922820 100644 --- a/src/noteburst/jupyterclient/jupyterlab.py +++ b/src/noteburst/jupyterclient/jupyterlab.py @@ -732,13 +732,22 @@ async def execute_notebook( content=json.dumps(notebook).encode("utf-8"), headers=headers, ) + except httpx.ReadTimeout as e: + raise JupyterError( + url=exec_url, + username=self.user.username, + status=r.status_code, + reason="/execution endpoint timeout", + method="POST", + body=str(e), + ) from e except httpx.HTTPError as e: # This often occurs from timeouts, so we want to convert the # generic HTTPError to a JupyterError. raise JupyterError( url=exec_url, username=self.user.username, - status=500, + status=r.status_code, reason="Internal Server Error", method="POST", body=str(e),