subprocess陷入poller.poll()

时间:2014-07-03 04:04:56

标签: python matlab nipype

我正在尝试在Nipype上运行一个简单的matlab接口,如下所示,但不知怎的,它被卡在run()代码中。我的命令行不再继续。但是如果我复制mlab.cmdline(matlab -nodesktop -nosplash -singleCompThread -r“addpath('/ somepath'); pyscript; exit”)并将其传递给命令行,它就能完美运行。

import nipype.interfaces.matlab as matlab

mlab = matlab.MatlabCommand()
mlab.inputs.script = """ 1+2 """

print mlab.cmdline
res = mlab.run()

print res.runtime

这里是ipython键盘中断:

    ^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    173             else:
    174                 filename = fname
--> 175             __builtin__.execfile(filename, *where)

/new_home/intern2012/yasin/example.py in <module>()
      6
      7 print mlab.cmdline
----> 8 res = mlab.run()
      9
     10 print res.runtime

/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run(self, **inputs)
    944                         version=self.version)
    945         try:
--> 946             runtime = self._run_interface(runtime)
    947             outputs = self.aggregate_outputs(runtime)
    948             runtime.endTime = dt.isoformat(dt.utcnow())

/usr/lib/pymodules/python2.7/nipype/interfaces/matlab.pyc in _run_interface(self, runtime)
    136     def _run_interface(self,runtime):
    137         self.inputs.terminal_output = 'allatonce'
--> 138         runtime = super(MatlabCommand, self)._run_interface(runtime)
    139         try:
    140             # Matlab can leave the terminal in a barbbled state


/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in _run_interface(self, runtime, correct_return_codes)
   1378         setattr(runtime, 'dependencies', get_dependencies(executable_name,
   1379                                                           runtime.environ))
-> 1380         runtime = run_command(runtime, output=self.inputs.terminal_output)
   1381         if runtime.returncode is None or \
   1382                         runtime.returncode not in correct_return_codes:

/usr/lib/pymodules/python2.7/nipype/interfaces/base.pyc in run_command(runtime, output, timeout)
   1150         result['merged'] = [r[1] for r in temp]
   1151     if output == 'allatonce':
-> 1152         stdout, stderr = proc.communicate()
   1153         result['stdout'] = stdout.split('\n')
   1154         result['stderr'] = stderr.split('\n')

/usr/lib/python2.7/subprocess.pyc in communicate(self, input)
    752             return (stdout, stderr)
    753
--> 754         return self._communicate(input)
    755
    756

/usr/lib/python2.7/subprocess.pyc in _communicate(self, input)
   1310
   1311             if _has_poll:
-> 1312                 stdout, stderr = self._communicate_with_poll(input)
   1313             else:
   1314                 stdout, stderr = self._communicate_with_select(input)

/usr/lib/python2.7/subprocess.pyc in _communicate_with_poll(self, input)
   1364             while fd2file:
   1365                 try:
-> 1366                     ready = poller.poll()
   1367                 except select.error, e:
   1368                     if e.args[0] == errno.EINTR:

我已阅读此网站中的其他subprocess个问题但这些问题都与Popen()有关。在我看来poller.poll()有问题。当它到达这一行时它不再处理。

1 个答案:

答案 0 :(得分:0)

我没有复制这种行为(又名“适合我!”)。您使用的是哪种版本的nipype?