python threading 一定要 join 吗?

2015-01-29 16:44:54 +08:00
 ryanking8215
参考pthread,如果不是detach的,需要join(),否则会有内存泄漏。
python的threaing不join()的话会有内存泄漏吗?pydoc没提。
7207 次点击
所在节点    Python
8 条回复
gdqyn
2015-01-29 16:57:41 +08:00
在我的实践过程中是见过有的
gdqyn
2015-01-29 16:59:18 +08:00
sorry看错了,是Python啊,Python不知道,丢人了
wuhang89
2015-01-29 17:33:07 +08:00
看具体项目,不过就python渣一般的线程也真无力吐槽了。
lazywen
2015-01-29 17:40:26 +08:00
不会内存泄露,看需求join
zerh925
2015-01-30 09:40:03 +08:00
不一定,join()是等待线程跑完,需要回调函数就join(),否则直接start就行了。
1989922yan
2015-01-30 14:06:32 +08:00
@zerh925 看文档中,一定需要join,应该是这样的
ryanking8215
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
2015-01-31 21:30:39 +08:00
Python的线程没有detach选项,
我记得是你得保证main线程一直在运行,就可以不去join

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/166537

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX