@@ -57,6 +57,7 @@ def start_zmq_server_as_subprocess(zmq_url=None, server_args=[]):
57
57
env = {'PYTHONPATH' : os .path .dirname (os .path .dirname (os .path .dirname (__file__ )))}
58
58
kwargs = {
59
59
'stdout' : subprocess .PIPE ,
60
+ 'stderr' : subprocess .PIPE ,
60
61
'env' : env
61
62
}
62
63
# Use start_new_session if it's available. Without it, in jupyter the server
@@ -67,6 +68,11 @@ def start_zmq_server_as_subprocess(zmq_url=None, server_args=[]):
67
68
line = ""
68
69
while "zmq_url" not in line :
69
70
line = server_proc .stdout .readline ().strip ().decode ("utf-8" )
71
+ if server_proc .poll () is not None :
72
+ outs , errs = server_proc .communicate ()
73
+ print (outs .decode ("utf-8" ))
74
+ print (errs .decode ("utf-8" ))
75
+ raise RuntimeError ("the meshcat server process exited prematurely with exit code " + str (server_proc .poll ()))
70
76
zmq_url = match_zmq_url (line )
71
77
web_url = match_web_url (server_proc .stdout .readline ().strip ().decode ("utf-8" ))
72
78
@@ -212,9 +218,16 @@ def f(port):
212
218
if sys .version_info .major >= 3 :
213
219
kwargs ['start_new_session' ] = True
214
220
config = pyngrok .conf .PyngrokConfig (** kwargs )
215
- self .web_url = pyngrok .ngrok .connect (self .fileserver_port , "http" , pyngrok_config = config ) + "/static/"
216
- print ("\n " ) # ensure any pyngrok output is properly terminated.
221
+ self .web_url = pyngrok .ngrok .connect (self .fileserver_port , "http" , pyngrok_config = config )
222
+
223
+ # pyngrok >= 5.0.0 returns an NgrokTunnel object instead of the string.
224
+ if sys .version_info .major < 3 :
225
+ self .web_url = self .web_url .decode ("utf-8" )
226
+ elif not isinstance (self .web_url , str ):
227
+ self .web_url = self .web_url .public_url
228
+ self .web_url += "/static/"
217
229
230
+ print ("\n " ) # ensure any pyngrok output is properly terminated.
218
231
def cleanup ():
219
232
pyngrok .ngrok .kill ()
220
233
0 commit comments