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

python threading 一定要 join 吗?

  •  
  •   ryanking8215 ·
    ryanking8215 · Jan 29, 2015 · 7980 views
    This topic created in 4120 days ago, the information mentioned may be changed or developed.
    参考pthread,如果不是detach的,需要join(),否则会有内存泄漏。
    python的threaing不join()的话会有内存泄漏吗?pydoc没提。
    8 replies    2015-01-31 21:30:39 +08:00
    gdqyn
        1
    gdqyn  
       Jan 29, 2015
    在我的实践过程中是见过有的
    gdqyn
        2
    gdqyn  
       Jan 29, 2015
    sorry看错了,是Python啊,Python不知道,丢人了
    wuhang89
        3
    wuhang89  
       Jan 29, 2015
    看具体项目,不过就python渣一般的线程也真无力吐槽了。
    lazywen
        4
    lazywen  
       Jan 29, 2015
    不会内存泄露,看需求join
    zerh925
        5
    zerh925  
       Jan 30, 2015
    不一定,join()是等待线程跑完,需要回调函数就join(),否则直接start就行了。
    1989922yan
        6
    1989922yan  
       Jan 30, 2015
    @zerh925 看文档中,一定需要join,应该是这样的
    ryanking8215
        7
    ryanking8215  
    OP
       Jan 30, 2015
    @1989922yan 文档里没说“一定”
    Other threads can call a thread’s join() method. This blocks the calling thread until the thread whose join() method is called is terminated.

    ‘can’
    inevermore
        8
    inevermore  
       Jan 31, 2015
    Python的线程没有detach选项,
    我记得是你得保证main线程一直在运行,就可以不去join
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   999 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 22:16 · PVG 06:16 · LAX 15:16 · JFK 18:16
    ♥ Do have faith in what you're doing.