Commit 853e7f3d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cli: Use new RPC call instead of polling

This means commands will not take at least one second anymore.

Reviewed-by: ultrotter
parent dfe57c22
...@@ -405,25 +405,25 @@ def PollJob(job_id, cl=None, feedback_fn=None): ...@@ -405,25 +405,25 @@ def PollJob(job_id, cl=None, feedback_fn=None):
if cl is None: if cl is None:
cl = GetClient() cl = GetClient()
state = None
lastmsg = None lastmsg = None
while True: while True:
jobs = cl.QueryJobs([job_id], ["status", "ticker"]) state = cl.WaitForJobChange(job_id, ["status", "ticker"], state)
if not jobs: if not state:
# job not found, go away! # job not found, go away!
raise errors.JobLost("Job with id %s lost" % job_id) raise errors.JobLost("Job with id %s lost" % job_id)
# TODO: Handle canceled and archived jobs # TODO: Handle canceled and archived jobs
status = jobs[0][0] status = state[0]
if status in (constants.JOB_STATUS_SUCCESS, constants.JOB_STATUS_ERROR): if status in (constants.JOB_STATUS_SUCCESS, constants.JOB_STATUS_ERROR):
break break
msg = jobs[0][1] msg = state[1]
if msg is not None and msg != lastmsg: if msg is not None and msg != lastmsg:
if callable(feedback_fn): if callable(feedback_fn):
feedback_fn(msg) feedback_fn(msg)
else: else:
print "%s %s" % (time.ctime(utils.MergeTime(msg[0])), msg[2]) print "%s %s" % (time.ctime(utils.MergeTime(msg[0])), msg[2])
lastmsg = msg lastmsg = msg
time.sleep(1)
jobs = cl.QueryJobs([job_id], ["status", "opresult"]) jobs = cl.QueryJobs([job_id], ["status", "opresult"])
if not jobs: if not jobs:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment