Python子进程不会终止

2024-04-25 12:36:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我在实际杀死在查看器中显示图像的子进程时遇到了问题。基本上,我是从堆栈中打开图片,并希望在一定时间内显示它们,然后终止子进程。当运行这个程序时,它显示了想要的图片,但我不能让实际的.kill或{}函数正常工作。在

class ImageDisplay(ThreadParent):
    def __init__(self, label):
        ThreadParent.__init__(self, label)
    def display_image(self):
        image = ThreadParent.image_stack.pop(0)
        cwd = os.getcwd()
        # Automagically opens in preview @ osx
        p = subprocess.Popen(["open", "file://%s/%s" % (cwd,
            filepath(filename(image)))])
        disptime = displaytime(image)
        print("Displaying image:", image, "for", disptime, "seconds..")
        time.sleep(disptime)
        p.terminate()
        p.kill()

我们将非常感谢所有的帮助。在

祝你一切顺利


Tags: 图像imageself进程init堆栈def时间
1条回答
网友
1楼 · 发布于 2024-04-25 12:36:35

我认为open将在预览打开后终止,这意味着您没有预览程序的句柄。尝试调用预览二进制文件,如下所示:

/Applications/Preview.app/Contents/MacOS/Preview /path/to/image.jpg

高温

相关问题 更多 >

    热门问题