@@ -314,6 +314,7 @@ def run():
314
314
pass
315
315
except Exception as error :
316
316
err_q .put (error )
317
+ raise error
317
318
318
319
thread = StoppableThread (target = run )
319
320
thread .setDaemon (True )
@@ -326,34 +327,41 @@ def run():
326
327
host = host , port = port , token = JupyterDash ._token
327
328
)
328
329
330
+ def _get_error ():
331
+ try :
332
+ err = err_q .get_nowait ()
333
+ if err :
334
+ raise err
335
+ except queue .Empty :
336
+ pass
337
+
329
338
# Wait for app to respond to _alive endpoint
330
339
@retry (
331
340
stop_max_attempt_number = 15 ,
332
341
wait_exponential_multiplier = 10 ,
333
342
wait_exponential_max = 1000
334
343
)
335
344
def wait_for_app ():
345
+ _get_error ()
336
346
try :
337
- err = err_q .get_nowait ()
338
- if err :
339
- raise err
340
- except queue .Empty :
341
- pass
342
- req = requests .get (alive_url )
343
- res = req .content .decode ()
344
- if req .status_code == 500 :
345
- raise Exception (res )
346
-
347
- if res != "Alive" :
348
- url = "http://{host}:{port}" .format (
349
- host = host , port = port , token = JupyterDash ._token
350
- )
351
- raise OSError (
352
- "Address '{url}' already in use.\n "
353
- " Try passing a different port to run_server." .format (
354
- url = url
347
+ req = requests .get (alive_url )
348
+ res = req .content .decode ()
349
+ if req .status_code != 200 :
350
+ raise Exception (res )
351
+
352
+ if res != "Alive" :
353
+ url = "http://{host}:{port}" .format (
354
+ host = host , port = port , token = JupyterDash ._token
355
355
)
356
- )
356
+ raise OSError (
357
+ "Address '{url}' already in use.\n "
358
+ " Try passing a different port to run_server." .format (
359
+ url = url
360
+ )
361
+ )
362
+ except requests .ConnectionError as err :
363
+ _get_error ()
364
+ raise err
357
365
358
366
try :
359
367
wait_for_app ()
@@ -363,7 +371,7 @@ def wait_for_app():
363
371
else :
364
372
self ._display_in_jupyter (dashboard_url , port , mode , width , height )
365
373
except Exception as final_error :
366
- msg = final_error . args [ 0 ]
374
+ msg = str ( final_error )
367
375
if msg .startswith ('<!' ):
368
376
display (HTML (msg ))
369
377
else :
0 commit comments