diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-01-24 17:30:09 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-01-24 17:30:09 -0500 |
commit | 8106c1d88407371505115e7938dc99bcaf6fb1e9 (patch) | |
tree | 7533cf08de4cf4f038a638c27dac8d438d6d6f65 /func/jobthing.py | |
parent | f3e03a6e1cf1696a5c194c662142ea0354726d9d (diff) | |
download | third_party-func-8106c1d88407371505115e7938dc99bcaf6fb1e9.tar.gz third_party-func-8106c1d88407371505115e7938dc99bcaf6fb1e9.tar.xz third_party-func-8106c1d88407371505115e7938dc99bcaf6fb1e9.zip |
Still working on async (pardon the debug output still), there's a long ways to go with the partial status
reporting but it is getting better at actually doing the task, just a few kinks to work out in getting
results reported correctly.
Diffstat (limited to 'func/jobthing.py')
-rw-r--r-- | func/jobthing.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/func/jobthing.py b/func/jobthing.py index 5b89599..a5b0820 100644 --- a/func/jobthing.py +++ b/func/jobthing.py @@ -28,7 +28,8 @@ import utils JOB_ID_RUNNING = 0 JOB_ID_FINISHED = 1 JOB_ID_LOST_IN_SPACE = 2 -JOB_ID_PARTIAL = 3 +JOB_ID_ASYNC_STATUS = 3 +JOB_ID_ASYNC_COMPLETE = 4 # how long to retain old job records in the job id database RETAIN_INTERVAL = 60 * 60 @@ -125,7 +126,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_PARTIAL, results) + __update_status(job_id, JOB_ID_ASYNC_STATUS, results) sys.exit(0) def minion_async_run(function_ref, args): @@ -154,36 +155,37 @@ def job_status(jobid, client_class=None): got_status = __get_status(jobid) - # if the status comes back as JOB_ID_PARTIAL what we have is actually a hash + # if the status comes back as JOB_ID_ASYNC_STATUS 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_PARTIAL: + if interim_rc == JOB_ID_ASYNC_STATUS: partial_results = {} + # print "DEBUG: partial results for batch task: %s" % interim_results + for host in interim_results.keys(): minion_job = interim_results[host] client = client_class(host, noglobs=True, async=False) - # print "DEBUG: client: %s" % client_class minion_result = client.jobs.job_status(minion_job) - # print "DEBUG: minion: %s" % minion_result + print "DEBUG: background task on minion (%s) has status %s" % (minion_job, minion_result) + (minion_interim_rc, minion_interim_result) = minion_result some_missing = False - if minion_interim_rc == JOB_ID_FINISHED: - partial_results[host] = minion_interim_result + if minion_interim_rc not in [ JOB_ID_RUNNING ]: + partial_results[host] = minion_interim_result else: - some_missing = True if some_missing: - return (JOB_ID_PARTIAL, partial_results) + return (JOB_ID_ASYNC_STATUS, partial_results) else: - return (JOB_ID_FINISHED, partial_results) + return (JOB_ID_ASYNC_COMPLETE, partial_results) else: return got_status |