Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Jobthing status codes cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof A. Adamski committed Jun 6, 2008
1 parent 3f62e1d commit 2d23caf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions func/jobthing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
JOB_ID_RUNNING = 0
JOB_ID_FINISHED = 1
JOB_ID_LOST_IN_SPACE = 2
JOB_ID_ASYNC_PARTIAL = 3
JOB_ID_ASYNC_FINISHED = 4
JOB_ID_PARTIAL = 3

# how long to retain old job records in the job id database
RETAIN_INTERVAL = 60 * 60
Expand Down Expand Up @@ -121,7 +120,7 @@ def batch_run(server, process_server, nforks):
results = forkbomb.batch_run(server, process_server, nforks)

# we now have a list of job id's for each minion, kill the task
__update_status(job_id, JOB_ID_ASYNC_PARTIAL, results)
__update_status(job_id, JOB_ID_PARTIAL, results)
sys.exit(0)

def minion_async_run(retriever, method, args):
Expand Down Expand Up @@ -158,13 +157,13 @@ def job_status(jobid, client_class=None):

got_status = __get_status(jobid)

# if the status comes back as JOB_ID_ASYNC_PARTIAL what we have is actually a hash
# if the status comes back as JOB_ID_PARTIAL what we have is actually a hash
# of hostname/minion-jobid pairs. Instantiate a client handle for each and poll them
# for their actual status, filling in only the ones that are actually done.

(interim_rc, interim_results) = got_status

if interim_rc == JOB_ID_ASYNC_PARTIAL:
if interim_rc == JOB_ID_PARTIAL:

partial_results = {}

Expand All @@ -187,9 +186,9 @@ def job_status(jobid, client_class=None):
some_missing = True

if some_missing:
return (JOB_ID_ASYNC_PARTIAL, partial_results)
return (JOB_ID_PARTIAL, partial_results)
else:
return (JOB_ID_ASYNC_FINISHED, partial_results)
return (JOB_ID_FINISHED, partial_results)

else:
return got_status
Expand Down
4 changes: 2 additions & 2 deletions func/overlord/cmd_modules/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def do(self, args):
(return_code, async_results) = self.overlord_obj.job_status(results)
if return_code == jobthing.JOB_ID_RUNNING:
time.sleep(0.1)
elif return_code == jobthing.JOB_ID_ASYNC_FINISHED:
elif return_code == jobthing.JOB_ID_FINISHED:
async_done = True
partial = self.print_partial_results(partial, async_results, self.options.sort)
return partial
elif return_code == jobthing.JOB_ID_ASYNC_PARTIAL:
elif return_code == jobthing.JOB_ID_PARTIAL:
if not self.options.sort:
partial = self.print_partial_results(partial, async_results)
else:
Expand Down
4 changes: 2 additions & 2 deletions test/async_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def __tester(async,test):
return
if code == jobthing.JOB_ID_RUNNING:
print "task is still running, %s elapsed ..." % delta
elif code == jobthing.JOB_ID_ASYNC_PARTIAL:
elif code == jobthing.JOB_ID_PARTIAL:
print "task reports partial status, %s elapsed, results = %s" % (delta, results)
elif code == jobthing.JOB_ID_FINISHED:
print "(non-async) task complete, %s elapsed, results = %s" % (delta, results)
return
elif code == jobthing.JOB_ID_ASYNC_FINISHED:
elif code == jobthing.JOB_ID_FINISHED:
print "(async) task complete, %s elapsed, results = %s" % (delta, results)
return
else:
Expand Down

0 comments on commit 2d23caf

Please sign in to comment.