fix: reconnect if stream closed (#8055)

This commit is contained in:
மனோஜ்குமார் பழனிச்சாமி 2025-04-24 17:35:28 +05:30 committed by GitHub
parent 356cd9ff9f
commit 00865fbb8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import re
from uuid import uuid4
import tornado
import tornado.websocket
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed
from tornado.escape import json_decode, json_encode, url_escape
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
@ -139,7 +140,7 @@ class JupyterKernel:
wait=wait_fixed(2),
)
async def execute(self, code: str, timeout: int = 120) -> str:
if not self.ws:
if not self.ws or self.ws.stream.closed():
await self._connect()
msg_id = uuid4().hex