29
29
from tornado .iostream import StreamClosedError
30
30
31
31
from jupyterhub .spawner import Spawner
32
+ from jupyterhub .traitlets import Command
32
33
from traitlets import (
33
34
Integer , Unicode , Float , Dict , default
34
35
)
@@ -73,6 +74,9 @@ class BatchSpawnerBase(Spawner):
73
74
state_gethost
74
75
"""
75
76
77
+ # override default since will need to set the listening port using the api
78
+ cmd = Command (['batchspawner-singleuser' ], allow_none = True ).tag (config = True )
79
+
76
80
# override default since batch systems typically need longer
77
81
start_timeout = Integer (300 ).tag (config = True )
78
82
@@ -342,14 +346,7 @@ def poll(self):
342
346
@gen .coroutine
343
347
def start (self ):
344
348
"""Start the process"""
345
- if self .user and self .user .server and self .user .server .port :
346
- self .port = self .user .server .port
347
- self .db .commit ()
348
- elif (jupyterhub .version_info < (0 ,7 ) and not self .user .server .port ) or (
349
- jupyterhub .version_info >= (0 ,7 ) and not self .port
350
- ):
351
- self .port = random_port ()
352
- self .db .commit ()
349
+ self .port = self .server .port = 0
353
350
job = yield self .submit_batch_script ()
354
351
355
352
# We are called with a timeout, and if the timeout expires this function will
@@ -374,6 +371,9 @@ def start(self):
374
371
yield gen .sleep (self .startup_poll_interval )
375
372
376
373
self .current_ip = self .state_gethost ()
374
+ while self .port == 0 :
375
+ yield gen .sleep (self .startup_poll_interval )
376
+
377
377
if jupyterhub .version_info < (0 ,7 ):
378
378
# store on user for pre-jupyterhub-0.7:
379
379
self .user .server .port = self .port
0 commit comments