@@ -29,42 +29,63 @@ async def get(self, url) -> None:
2929 try :
3030 client = httpclient .AsyncHTTPClient ()
3131
32- # Check the user-provided url, following any redirects.
32+ # First check for the individual-plots endpoint at user-provided url.
33+ # We don't check for the root URL because that can trigger a lot of
34+ # object creation in the bokeh document.
3335 url = _normalize_dashboard_link (parse .unquote (url ), self .request )
36+ effective_url = None
37+ individual_plots_url = url_path_join (
38+ url ,
39+ "individual-plots.json" ,
40+ )
3441 try :
42+ self .log .debug (
43+ f"Checking for individual plots at { individual_plots_url } "
44+ )
45+ individual_plots_response = await client .fetch (individual_plots_url )
46+ self .log .debug (f"{ individual_plots_response .code } " )
47+ except httpclient .HTTPError as err :
48+ # If we didn't get individual plots, we may have to follow a redirect first.
49+ self .log .debug (f"Checking for redirect at { url } " )
3550 response = await client .fetch (url )
3651 effective_url = (
37- response .effective_url if response .effective_url != url else None
52+ _normalize_dashboard_link (response .effective_url , self .request )
53+ if response .effective_url != url
54+ else None
3855 )
39- except httpclient .HTTPError :
40- # The page at /individual-plots.html might be available, even if `/` isn't.
41- effective_url = None
56+ # If there was no redirect, raise.
57+ if not effective_url :
58+ raise err
59+
60+ individual_plots_url = url_path_join (
61+ effective_url ,
62+ "individual-plots.json" ,
63+ )
64+ self .log .debug (f"Found redirect at { effective_url } " )
65+ self .log .debug (
66+ f"Checking for individual plots at { individual_plots_url } "
67+ )
68+ individual_plots_response = await client .fetch (individual_plots_url )
4269
43- # Fetch the individual plots
44- individual_plots_url = url_path_join (
45- _normalize_dashboard_link (effective_url or url , self .request ),
46- "individual-plots.json" ,
47- )
48- self .log .info ("Checking for individual plots at %s" , individual_plots_url )
49- individual_plots_response = await client .fetch (individual_plots_url )
5070 # If we didn't get individual plots, it may not be a dask dashboard
5171 if individual_plots_response .code != 200 :
5272 raise ValueError ("Does not seem to host a dask dashboard" )
73+
5374 individual_plots = json .loads (individual_plots_response .body )
5475
5576 self .set_status (200 )
5677 self .finish (
5778 json .dumps (
5879 {
5980 "url" : url ,
60- "isActive" : individual_plots_response . code == 200 ,
81+ "isActive" : True ,
6182 "effectiveUrl" : effective_url ,
6283 "plots" : individual_plots ,
6384 }
6485 )
6586 )
6687 except Exception :
67- self .log .exception (f"{ url } does not seem to host a dask dashboard" )
88+ self .log .debug (f"{ url } does not seem to host a dask dashboard" )
6889 self .set_status (200 )
6990 self .finish (
7091 json .dumps (
0 commit comments