Skip to content

Commit

Permalink
batchspawner/batchspawner: Fixups of jupyterhub#179
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdarst committed Jul 29, 2020
1 parent fc522b6 commit e6c0a3e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions batchspawner/batchspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ async def query_job_status(self):
try:
self.job_status = await self.run_command(cmd)
except RuntimeError as e:
# e.args[0] is stderr from the process
self.job_status = e.args[0]
except Exception as e:
self.log.error('Error querying job ' + self.job_id)
Expand Down Expand Up @@ -343,7 +344,7 @@ def state_isrunning(self):

def state_isunknown(self):
"Return boolean indicating if job state retrieval failed because of the resource manager"
raise False
return None

def state_gethost(self):
"Return string, hostname or addr of running job, likely by parsing self.job_status"
Expand Down Expand Up @@ -425,7 +426,7 @@ async def stop(self, now=False):
return
for i in range(10):
status = await self.query_job_status()
if not status in (JobStatus.RUNNING, JobStatus.UNKNOWN):
if status not in (JobStatus.RUNNING, JobStatus.UNKNOWN):
return
await gen.sleep(1.0)
if self.job_id:
Expand Down Expand Up @@ -481,8 +482,9 @@ class BatchSpawnerRegexStates(BatchSpawnerBase):
If this variable is set, the match object will be expanded using this string
to obtain the notebook IP.
See Python docs: re.match.expand""").tag(config=True)
state_unknown_re = Unicode('^$',
help="Regex that matches job_status if the resource manager is not answering").tag(config=True)
state_unknown_re = Unicode('',
help="Regex that matches job_status if the resource manager is not answering."
"Blank indicates not used.").tag(config=True)

def state_ispending(self):
assert self.state_pending_re, "Misconfigured: define state_running_re"
Expand All @@ -493,8 +495,9 @@ def state_isrunning(self):
return self.job_status and re.search(self.state_running_re, self.job_status)

def state_isunknown(self):
assert self.state_unknown_re, "Misconfigured: define state_unknown_re"
return self.job_status and re.search(self.state_unknown_re, self.job_status)
# Blank means "not set" and this function always returns None.
if self.state_unknown_re:
return self.job_status and re.search(self.state_unknown_re, self.job_status)

def state_gethost(self):
assert self.state_exechost_re, "Misconfigured: define state_exechost_re"
Expand Down

0 comments on commit e6c0a3e

Please sign in to comment.