How to get number of tasks queued and completed

I’m also struggling to find out in a post job script how many tasks have been completed and how many are still queued.

This is what I’ve tried in the script:

job = deadlinePlugin.GetJob() print job.JobQueuedTasks print job.JobCompletedTasks

But the job queued tasks number stays the same and doesn’t decrease, and the job completed tasks remains at zero even when all the tasks are complete.

I’m sure it’s something simple, but what am I missing?

1 Like

Split this off as it is a different topic

A post job script wouldn’t run until the entire job was completed in all it’s tasks. We’ll have to do some investigating here to figure out why it’s not returning the expected data.

Sorry, my bad, I meant post task script…

After a bit more post task script testing I’ve found that JobQueuedTasks and JobCompletedTasks give the correct output immediately after a job is started or resumed, but then they remain the same even as subsequent tasks are completed.

Is this because the args provided to the post task script are provided when a job is started or resumed and then not updated in between tasks? And if this is the case, is there any way to query how many tasks are left from a post task script?

2 Likes

Yup, the plugin’s GetJob function doesn’t get the ‘latest’ state of the Job, it just returns the cached value it got when it first de-queued the Job.

To get the latest value you can use the RepositoryUtils.GetJob fuction (docs here). Make sure to pass in ‘True’ as the second argument, or you’ll just get the cached value back again :slight_smile:

job = deadlinePlugin.GetJob() job = RepositoryUtils.GetJob( job.JobId, True ) print job.JobQueuedTasks print job.JobCompletedTasks

Hope this helps!

  • Jon