...
The example is also available as an attachment.
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/env python import sys,os sys.path.append('%s/api/python' % os.environ['QBDIR']) import qb scriptPathOnSupervisor = '/Users/jburk/test/testCbScript.py' ######################################## # build the job ######################################## job = { 'prototype': 'cmdrange', 'name': 'supervisor-side script execution callback test', 'package': {'cmdline': 'hostname'}, 'agenda': [], 'callbacks': [ ] } ######################################## # iterate over the frame range to build the job's agenda and callbacks ######################################## for i in range(5): # an agenda item can simply be a frame number work = {'name': i} job['agenda'].append(work) # build a callback for each item in the agenda (each frame) cb = { 'language': 'python', 'triggers': 'done-job-self', 'code': ''' import os jobId = qb.jobid() workName = %s script = '%s' if os.path.exists(script): pid = os.spawnl(os.P_NOWAIT, script, os.path.basename(script), str(jobId), str(workName)) ''' % (i, scriptPathOnSupervisor) } # append the frame's callback to the job's callback list job['callbacks'].append(cb) ######################################## # submit the job ######################################## submitted = qb.submit(job) for job in submitted: print 'submitted %(id)s: %(name)s' % job |
...