Jython 2.7.0的subprocess.Popen
实现似乎没有对stdout
传入的句柄的引用,这与CPython 2.7.10的行为形成对比。这是一个Jython错误还是符合Python实现,允许在这些情况下垃圾收集文件句柄fh
?
例如,
import subprocess
perl_loop = """
$c = 0;
while (1) {
print "$c\n";
$c++;
}
"""
def func():
fh = open('./counter.out', 'a')
process_handle = subprocess.Popen(
["perl", "-e", perl_loop],
stdout=fh)
return process_handle
func().wait()
一段时间后,在stderr上产生以下输出
Exception in thread "_CouplerThread-2 (stdout)" Traceback (most recent call last):
File "<home-directory>/bin/jython-standalone-2.7.0.jar/Lib/subprocess.py", line 754, in run
IOError: java.nio.channels.ClosedChannelException