推荐学习书目
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
loriann
V2EX  ›  Python

Python 进程和线程问题,请指教

  •  
  •   loriann · Apr 15, 2020 · 2300 views
    This topic created in 2234 days ago, the information mentioned may be changed or developed.

    假设我创建了 5 个线程,在这 5 个线程中使用了 popen 函数。那这 5 个线程是复制了 5 个父进程的信息吗。新创建的子进程会不会也有 5 个线程?

    Nitroethane
        1
    Nitroethane  
       Apr 15, 2020
    Linux 下,在一个多线程的进程中,每个 thread 里 fork 一个 child process 的话每个新的 child process 只有创建此 process 的 thread,即只存在一个 thread
    Reference: https://stackoverflow.com/a/39890957/6628963
    loriann
        2
    loriann  
    OP
       Apr 15, 2020
    谢谢,我刚才我试验了一下,确实 fork 的进程只有一个线程
    frostming
        3
    frostming  
       Apr 16, 2020
    popen 并不是 fork 出来的而是 spawn 出来的,进程信息跟父进程不共享
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   926 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 20:38 · PVG 04:38 · LAX 13:38 · JFK 16:38
    ♥ Do have faith in what you're doing.