首页 > 解决方案 > 如何让jupyter中的子进程保持活动状态

问题描述

我有一个 jupyter 笔记本,它正在使用 Google Earth Engine 进行地理空间分析,然后使用%run命令调用脚本。在该脚本中,从 GEE 发送要下载的任务后,我有一个子进程,每 60 秒检查一次任务是否完成(开始与 GDrive 的连接,然后下载图像)。我想知道的是为什么 - 在我关闭 jupyter notebook 之后 - 并且导出进程的 PID 仍在运行,似乎进程已经结束,没有完成可能需要几个小时的“while 循环”。

def export_images(tasks_file_name, out_path):
    process = subprocess.Popen(['python3',  '/home/download.py',
                                tasks_file_name,
                                out_path
                            ],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE, 
                            universal_newlines=True)
    return process

标签: pythonsubprocessgoogle-earth-engine

解决方案


推荐阅读