狗仔小分队的博客

  • 服务器
    • 干货推荐
    • 教程&一键脚本
    • 特价监控
  • 实用工具
    • 小工具汇总
  • 教程
    • Ubuntu
    • Python
    • 学习
  • 福利
    • 商城
    • 薅羊毛
    • 影视&资源推荐
  1. 首页
  2. 教程
  3. Python
  4. 正文

python 多线程 整理

2017年5月29日 2638点热度 1人点赞 0条评论

整理下python多线程的方法,持续更新

[title]ThreadPool 线程池方法[/title]

from multiprocessing.dummy import Pool as ThreadPool 
pool = ThreadPool(10) # 10个线程
results = pool.map(lambda x: x, urls) # urls是任务列表 list,第一个参数是线程函数
# close the pool and wait for the work to finish 
pool.close() 
pool.join() 
# 最后得到的results,为各个线程的返回结果

[title]Thread Class类 方法[/title]

汤不热爬虫项目:先收藏以后学习整理下:https://github.com/dixudx/tumblr-crawler/blob/master/tumblr-photo-video-ripper.py

标签: python 多线程
最后更新:2017年10月14日

xiaofd

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2021 xiaofd.net. ALL RIGHTS RESERVED.

THEME KRATOS MADE BY VTROIS