V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2015-01-29 16:44:54 +08:00 · 7199 次点击
    这是一个创建于 3373 天前的主题,其中的信息可能已经有所发展或是发生改变。
    参考pthread,如果不是detach的,需要join(),否则会有内存泄漏。
    python的threaing不join()的话会有内存泄漏吗?pydoc没提。
    8 条回复    2015-01-31 21:30:39 +08:00
    gdqyn
        1
    gdqyn  
       2015-01-29 16:57:41 +08:00
    在我的实践过程中是见过有的
    gdqyn
        2
    gdqyn  
       2015-01-29 16:59:18 +08:00
    sorry看错了,是Python啊,Python不知道,丢人了
    wuhang89
        3
    wuhang89  
       2015-01-29 17:33:07 +08:00
    看具体项目,不过就python渣一般的线程也真无力吐槽了。
    lazywen
        4
    lazywen  
       2015-01-29 17:40:26 +08:00
    不会内存泄露,看需求join
    zerh925
        5
    zerh925  
       2015-01-30 09:40:03 +08:00
    不一定,join()是等待线程跑完,需要回调函数就join(),否则直接start就行了。
    1989922yan
        6
    1989922yan  
       2015-01-30 14:06:32 +08:00
    @zerh925 看文档中,一定需要join,应该是这样的
    ryanking8215
        7
    ryanking8215  
    OP
       2015-01-30 17:08:51 +08:00
    @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  
       2015-01-31 21:30:39 +08:00
    Python的线程没有detach选项,
    我记得是你得保证main线程一直在运行,就可以不去join
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   6015 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 02:14 · PVG 10:14 · LAX 19:14 · JFK 22:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.