Skip to content

Commit b398ef7

Browse files
committed
capture the HTTPTimeoutError and return 408
1 parent 591f294 commit b398ef7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

jupyter_server_proxy/handlers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import aiohttp
1212
from asyncio import Lock
1313

14-
from tornado import gen, web, httpclient, httputil, process, websocket, ioloop, version_info
14+
from tornado import gen, web, httpclient, simple_httpclient, httputil, process, websocket, ioloop, version_info
1515

1616
from notebook.utils import url_path_join
1717
from notebook.base.handlers import IPythonHandler, utcnow
@@ -213,7 +213,15 @@ async def proxy(self, host, port, proxied_path):
213213
client = httpclient.AsyncHTTPClient()
214214

215215
req = self._build_proxy_request(host, port, proxied_path, body)
216-
response = await client.fetch(req, raise_error=False)
216+
217+
try:
218+
response = await client.fetch(req, raise_error=False)
219+
except simple_httpclient.HTTPTimeoutError as err:
220+
self._record_activity()
221+
self.set_status(408)
222+
self.write(str(err))
223+
return
224+
217225
# record activity at start and end of requests
218226
self._record_activity()
219227

0 commit comments

Comments
 (0)