推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
eccentric579
V2EX  ›  Python

Python 如何创建独立的进程

  •  
  •   eccentric579 · Dec 10, 2021 · 3636 views
    This topic created in 1627 days ago, the information mentioned may be changed or developed.

    试过了如下的代码,还是会随着主进程结束而结束

    试想的情况是主进程创建完这个进程,主进程退出,后台进程继续运行。

    subprocess.Popen([path], creationflags=subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP)
    
    6 replies    2021-12-11 12:39:29 +08:00
    vincent441
        1
    vincent441  
       Dec 10, 2021
    子进程继续进行
    julyclyde
        2
    julyclyde  
       Dec 10, 2021
    我觉得似乎是主进程主动干掉子进程的?销毁对象的时候?
    eccentric579
        4
    eccentric579  
    OP
       Dec 10, 2021
    代码没问题,是 vscode 调试终止了所有进程。。。
    以上
    ysc3839
        5
    ysc3839  
       Dec 10, 2021
    Windows 下直接 subprocess.Popen("command") 是可以继续运行的
    ClericPy
        6
    ClericPy  
       Dec 11, 2021
    DETACHED_PROCESS 参数以前居然一直没用过, 用的 os.startfile... 长见识了先赞为敬
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3516 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 11:16 · PVG 19:16 · LAX 04:16 · JFK 07:16
    ♥ Do have faith in what you're doing.