摘要: 线程池可以自动分配线程。pip install threadpool 例子: 二、线程池threading.pool的基本用法 参考: threadpool的官方网站 pypi页面 google code源码 安装: pip install threadpool 0x01 代码剖析 创建线程池,线程 阅读全文
posted @ 2019-07-25 15:10 4jd121de2gf4e2sa5d 阅读(125) 评论(0) 推荐(0) 编辑
摘要: import request,threading,hashlib,time def down_load_file(url): r=request.get(url) m=hashlib.md5(url.encode()) print('开始下载%s'%m.hexdigest()) with open ('%s.jpg'%m.hexdigest(),wb) as f... 阅读全文
posted @ 2019-07-25 14:39 4jd121de2gf4e2sa5d 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 守护线程: 只要主线程运行完,无论子线程是否运行完,都会结束。 阅读全文
posted @ 2019-07-25 11:45 4jd121de2gf4e2sa5d 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 一、概念: 进程:对系统过来说,一个任务是一个进程; 线程:线程是包含在进程中。进程中,线程来工作,线程是最小的单位。一个进程可以启多个线程 二、进程和线程使用时的选择: 1.cpu密集型任务,用进程 #比如排序、计算的功能2.IO密集型任务,多线程 input Output #读写频繁,网络IO或 阅读全文
posted @ 2019-07-25 11:32 4jd121de2gf4e2sa5d 阅读(195) 评论(0) 推荐(0) 编辑