Skip to content

Commit 9bac20e

Browse files
authored
Merge pull request #1 from hypergravity/master
popen2 replaced by subprocess
2 parents 4e7bf6c + 0812c52 commit 9bac20e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

submit-pbs-loop.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python
22
# Example PBS cluster job submission in Python
33

4-
from popen2 import popen2
4+
from subprocess import Popen, PIPE
55
import time
66

77
# If you want to be emailed by the system, include these in job_string:
@@ -12,7 +12,7 @@
1212
for i in range(1, 10):
1313

1414
# Open a pipe to the qsub command.
15-
output, input = popen2('qsub')
15+
proc = Popen('qsub', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
1616

1717
# Customize your options here
1818
job_name = "my_job_%d" % i
@@ -30,11 +30,11 @@
3030
%s""" % (job_name, walltime, processors, job_name, job_name, command)
3131

3232
# Send job_string to qsub
33-
input.write(job_string)
34-
input.close()
33+
proc.stdin.write(job_string)
34+
out, err = proc.communicate()
3535

3636
# Print your job and the system response to the screen as it's submitted
3737
print job_string
38-
print output.read()
38+
print out
3939

40-
time.sleep(0.1)
40+
time.sleep(0.1)

0 commit comments

Comments
 (0)