File: example4.py

package info (click to toggle)
drmaa 0.7.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 360 kB
  • sloc: python: 1,295; makefile: 130; sh: 34
file content (30 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python

from __future__ import print_function
import drmaa
import os

def main():
    """Submit a job, then kill it.
    Note, need file called sleeper.sh in home directory.
    """
    s = drmaa.Session()
    s.initialize()
    print('Creating job template')
    jt = s.createJobTemplate()
    jt.remoteCommand = os.getcwd() + '/sleeper.sh'
    jt.args = ['42','Simon says:']
    jt.joinFiles = True
    
    jobid = s.runJob(jt)
    print('Your job has been submitted with id ' + jobid)
    # options are: SUSPEND, RESUME, HOLD, RELEASE, TERMINATE
    s.control(jobid, drmaa.JobControlAction.TERMINATE)

    print('Cleaning up')
    s.deleteJobTemplate(jt)
    s.exit()
    

if __name__=='__main__':
    main()