您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python-从Web应用程序启动长时间运行的进程

Python-从Web应用程序启动长时间运行的进程

好吧,我终于明白了!这似乎可行:

from subprocess import Popen
from win32process import DETACHED_PROCESS

pid = Popen(["C:\python24\python.exe", "long_run.py"],creationflags=DETACHED_PROCESS,shell=True).pid
print pid
print 'done' 
#I can Now close the console or anything I want and long_run.py continues!

注意:我添加了shell = True。否则在子进程中调用print会给我错误“ IOError:[Errno 9]错误文件描述符”

DETACHED_PROCESS一个过程创建标志,该标志被传递给基础WINAPICreateProcess函数

python 2022/1/1 18:52:16 有389人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶