Author Topic: python help with subjob time  (Read 10178 times)

pinkwerks

  • Sr. Member
  • ****
  • Posts: 26
    • Method Studios
python help with subjob time
« on: March 19, 2009, 01:54:47 AM »
Hi, i'm trying to check for renders going over a certain amount of time.  I'm including a bit of code, but I can't seem to get values that make sense.  Anyone see something I'm doing wrong?  My values are reporting much larger than the QubeGUI for the elapsed time.  Maybe there is a way to grab the elapsed time directly?

---

#!/usr/bin/python

import qb

mins = 10
print 'Checking for active jobs running over %d minutes' % mins

jobs = qb.jobinfo(status='running', subjobs=True)
now = qb.currenttime()
print 'Current time = %d' % now

print 'Running jobs:'
for job in jobs:
   for subjob in job['subjobs']:
      delta = (now - subjob['timestart']) / 60
      print 'job-id = %d' % job['id']
#      print '\t'+str(subjob)
      print '\tsubjob-id        = %d' % subjob['id']
      print '\t\tsubjob-start   = %d' % subjob['timestart']
      print '\t\tactive minutes = %d' % delta

Scot Brew

  • Hero Member
  • *****
  • Posts: 272
    • PipelineFX
Re: python help with subjob time
« Reply #1 on: March 19, 2009, 02:33:01 AM »
Your script seems to be working as expected when running on a test system here.  A single sleep job was submitted.  Here are the results:

Code: [Select]
MyMac:tmp tmpuser$ python subjobScanner.py
Checking for active jobs running over 10 minutes
Current time = 1237418757
Running jobs:
job-id = 2569
subjob-id        = 0
subjob-start   = 1237418623
active minutes = 2

The datetime.datetime.fromtimestamp(qb.currenttime()) function may make the timestamp more readable for you.  For example:

Code: [Select]
>>> datetime.datetime.fromtimestamp(qb.currenttime())
datetime.datetime(2009, 3, 18, 16, 28, 7)

What are the results that you are seeing in the output?

pinkwerks

  • Sr. Member
  • ****
  • Posts: 26
    • Method Studios
Re: python help with subjob time
« Reply #2 on: March 19, 2009, 06:07:32 PM »
Ah I think I've figured it out.  I was thinking subjob == frame. The subjob times seem to be different than frame times.  I'm going to rework things to sift through the agenda frames instead.

This morning for instance we had 3 frames that hung up and ran for 14+ hours.  I'm trying to write something that combs through the queue via a cron job and kills off rogues.  Before I get too deep into this - is this feature already in qube?