@@ -282,6 +282,7 @@ async def query_job_status(self):
282282 try :
283283 self .job_status = await self .run_command (cmd )
284284 except RuntimeError as e :
285+ # e.args[0] is stderr from the process
285286 self .job_status = e .args [0 ]
286287 except Exception as e :
287288 self .log .error ('Error querying job ' + self .job_id )
@@ -343,7 +344,7 @@ def state_isrunning(self):
343344
344345 def state_isunknown (self ):
345346 "Return boolean indicating if job state retrieval failed because of the resource manager"
346- raise False
347+ return None
347348
348349 def state_gethost (self ):
349350 "Return string, hostname or addr of running job, likely by parsing self.job_status"
@@ -425,7 +426,7 @@ async def stop(self, now=False):
425426 return
426427 for i in range (10 ):
427428 status = await self .query_job_status ()
428- if not status in (JobStatus .RUNNING , JobStatus .UNKNOWN ):
429+ if status not in (JobStatus .RUNNING , JobStatus .UNKNOWN ):
429430 return
430431 await gen .sleep (1.0 )
431432 if self .job_id :
@@ -481,8 +482,9 @@ class BatchSpawnerRegexStates(BatchSpawnerBase):
481482 If this variable is set, the match object will be expanded using this string
482483 to obtain the notebook IP.
483484 See Python docs: re.match.expand""" ).tag (config = True )
484- state_unknown_re = Unicode ('^$' ,
485- help = "Regex that matches job_status if the resource manager is not answering" ).tag (config = True )
485+ state_unknown_re = Unicode ('' ,
486+ help = "Regex that matches job_status if the resource manager is not answering."
487+ "Blank indicates not used." ).tag (config = True )
486488
487489 def state_ispending (self ):
488490 assert self .state_pending_re , "Misconfigured: define state_running_re"
@@ -493,8 +495,9 @@ def state_isrunning(self):
493495 return self .job_status and re .search (self .state_running_re , self .job_status )
494496
495497 def state_isunknown (self ):
496- assert self .state_unknown_re , "Misconfigured: define state_unknown_re"
497- return self .job_status and re .search (self .state_unknown_re , self .job_status )
498+ # Blank means "not set" and this function always returns None.
499+ if self .state_unknown_re :
500+ return self .job_status and re .search (self .state_unknown_re , self .job_status )
498501
499502 def state_gethost (self ):
500503 assert self .state_exechost_re , "Misconfigured: define state_exechost_re"
0 commit comments