Skip to content

Commit 0729028

Browse files
authored
Modified time.sleep(1) delay amount
Modified time.sleep(1) delay amount to give glowscript more time to launch before opening up Comm channel. Also modified code for VPython on JupyterHub
1 parent 88212d5 commit 0729028

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

vpython/with_notebook.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ def find_free_port():
5858
if jupyterlab.__version__ >= '0.35.0':
5959
from os.path import join
6060
labextensions_dir = join(jupyterlab.commands.get_app_dir(), u'static')
61-
notebook.nbextensions.install_nbextension(path=package_dir + "/vpython_data",
62-
nbextensions_dir=labextensions_dir,
63-
overwrite=False,
64-
verbose=0)
61+
try:
62+
notebook.nbextensions.install_nbextension(path=package_dir + "/vpython_data",
63+
nbextensions_dir=labextensions_dir,
64+
overwrite=False,
65+
verbose=0)
66+
except PermissionError:
67+
#logging.info("PermissionError: Unable to install /vpython_data directory and files for VPython on JupyterLab")
68+
pass
69+
6570

6671
if 'nbextensions' in os.listdir(jd):
6772
ldir = os.listdir(nbdir)
@@ -101,7 +106,10 @@ def find_free_port():
101106
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glowcomm"], function(){console.log("GLOWCOMM LOADED");});}else{element.textContent = ' ';}"""))
102107
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/jquery-ui.custom.min"], function(){console.log("JQUERY LOADED");});}else{element.textContent = ' ';}"""))
103108

104-
time.sleep(1) # allow some time for javascript code above to run before attempting to setup Comm Channel
109+
if transfer:
110+
time.sleep(4) # allow some time for javascript code above to run after nbextensions update before attempting to setup Comm Channel
111+
else:
112+
time.sleep(2) # allow some time for javascript code above to run before attempting to setup Comm Channel
105113

106114
wsConnected = False
107115

0 commit comments

Comments
 (0)