Skip to content

Commit b1774f9

Browse files
committed
fix: changed sge to use subprocess directly
1 parent d5620ff commit b1774f9

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

nipype/pipeline/plugins/pbs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _is_pending(self, taskid):
3939
proc = subprocess.Popen(["qstat", taskid],
4040
stdout=subprocess.PIPE,
4141
stderr=subprocess.PIPE)
42-
o,e=proc.communicate()
42+
_, e = proc.communicate()
4343
errmsg = 'Unknown Job Id' # %s' % taskid
4444
return errmsg not in e
4545

nipype/pipeline/plugins/sge.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"""
33

44
import os
5+
import subprocess
6+
from time import sleep
57

68
from .base import (SGELikeBatchManagerBase, logger, iflogger, logging)
79

810
from nipype.interfaces.base import CommandLine
911

10-
from time import sleep
1112

1213
class SGEPlugin(SGELikeBatchManagerBase):
1314
"""Execute using SGE (OGE not tested)
@@ -36,16 +37,11 @@ def __init__(self, **kwargs):
3637
super(SGEPlugin, self).__init__(template, **kwargs)
3738

3839
def _is_pending(self, taskid):
39-
cmd = CommandLine('qstat')
40-
cmd.inputs.args = '-j %d' % taskid
41-
# check sge task
42-
oldlevel = iflogger.level
43-
iflogger.setLevel(logging.getLevelName('CRITICAL'))
44-
result = cmd.run(ignore_exception=True)
45-
iflogger.setLevel(oldlevel)
46-
if result.runtime.stdout.startswith('='):
47-
return True
48-
return False
40+
proc = subprocess.Popen(["qstat", '-j', taskid],
41+
stdout=subprocess.PIPE,
42+
stderr=subprocess.PIPE)
43+
o, _ = proc.communicate()
44+
return o.startswith('=')
4945

5046
def _submit_batchtask(self, scriptfile, node):
5147
cmd = CommandLine('qsub', environ=os.environ.data)

0 commit comments

Comments
 (0)