【发布时间】:2021-10-31 07:37:27
【问题描述】:
我环顾四周,但没有看到有关此特定问题的任何信息,所以我想在这里问一下:
每当我在启动随机线程后尝试运行 subprocess.Popen 调用时,都会收到 OSError。我的假设是 subprocess.py 的某些方面我不了解与多线程相关的内容。
我在 QNX 系统上运行 python 2.7.3。
代码测试:
import subprocess
import time
from threading import Thread
def Test():
while(1):
print "Testing."
time.sleep(1)
if __name__=="__main__":
subprocess.Popen('ls') # runs just fine
Thread(target=Test).start()
subprocess.Popen('ls') # throws OSError
追溯
Traceback (most recent call last):
File "test.py", line 16 in <module>
subprocess.Popen('ls')
File "usr/local/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "usr/local/lib/python2.7/subprocess.py", line 1143, in _execute_child
self.pid = os.fork()
OSError: [Errno 89] Function not implemented
【问题讨论】:
-
这似乎是操作系统特定的问题。您是否尝试过先评论
Popen()电话? -
@OlvinRoght 是的,它会产生同样的错误。
-
在
multiprocessing你可以change start method 来“生成”。看看吧。 -
@OliveRoght 这仅适用于 Python 3.4 及更高版本。
标签: python subprocess qnx