【发布时间】:2017-01-03 15:16:20
【问题描述】:
我只是试图在监视文件是否仍然打开的同时进行文件的基本打开,但它只是打开它并退出。关于为什么会发生这种情况的任何建议?
class Opener:
def __init__(self, file_path):
self.file_path = file_path
self.process = None
def start(self):
sub = subprocess.Popen(self.file_path, shell=True)
while sub.poll():
pass
print "closed"
new = Opener("test.jpg")
t1 = threading.Thread(target=new.start)
t1.start()
【问题讨论】:
-
Popen将可执行文件作为参数,而不是图像。你想达到什么目标? -
我使用了 shell 参数,它像在命令行上一样运行参数,它会按原样打开图片,但它会等到它关闭
-
你用的是windows还是linux?
标签: python multithreading subprocess