OK 这一篇主要是协程的,还落下了点线程的方法,先说线程, 一. 线程池 线程池顾名思义就是跟是跟进程池一样的 到这里就差我们的线程池没有讲了,我们用一个新的模块给大家讲,早期的时候我们没有线程池,现在python提供了一个新的标准或者说内置的模块,这个模块里面提供了新的线程池和进程池,之前我们说的 ...
分类:
编程语言 时间:
2019-01-14 23:09:42
阅读次数:
212
from concurrent.futuress import ThreadPoolExecutor,ProcessPoolExecutor def f1(n,s): return n+s def f2(n): print('回调函数>>>',n.result()) if __name__ == ' ...
分类:
编程语言 时间:
2019-01-14 23:04:51
阅读次数:
211
import time from comcurrent.futures import ThreadPoolExecutor,ProcessPoolExccoutor#这个方法可以用进程池或者线程池 def f1(i): print(i) time.sleep(2) if __name__ == '_ ...
分类:
编程语言 时间:
2019-01-14 21:24:26
阅读次数:
228
目标站点需求分析 涉及的库 获取单页源码 解析单页源码 保存到文件中 开启多进程获取多个页面抓取 ...
分类:
编程语言 时间:
2019-01-14 20:17:16
阅读次数:
235
一、如何查看线程的id和名字 二、线程池 线程池的回调函数 三、协程 gevent 四、greenlet模块 五、先进后出和优先级队列 ...
分类:
编程语言 时间:
2019-01-14 18:52:17
阅读次数:
203
import time from multiprocessing import Process,Pool def f1(n): time.sleep(1) # print(n) return n*n if __name__ == '__main__': pool = Pool(4) for i in... ...
分类:
系统相关 时间:
2019-01-14 15:59:47
阅读次数:
147
import time from multiprocessing import Process,Pool def f1(n): time.sleep(0.5) # print(n) return n*n if __name__ == '__main__': pool = Pool(4) # pool... ...
分类:
系统相关 时间:
2019-01-14 15:58:53
阅读次数:
214
import time from multiprocessing import Process,Pool # def f1(n): # time.sleep(1) # print(n) #对比多进程和进程池的效率 def f1(n): for i in range(5): n = n + i if ... ...
分类:
系统相关 时间:
2019-01-14 15:56:22
阅读次数:
187
进程 本节目录 本节目录 一 背景知识 二 什么是进程 三 进程调度 四 并发与并行 五 同步\异步\阻塞\非阻塞 六 进程的创建与结束 七 multiprocess模块 八 进程池和mutiprocess.Poll 一 背景知识 二 什么是进程 三 进程调度 四 并发与并行 五 同步\异步\阻塞\ ...
分类:
编程语言 时间:
2019-01-13 11:37:22
阅读次数:
179
Python进程池的使用请点击:https://www.cnblogs.com/lowmanisbusy/p/10259235.html ...
分类:
编程语言 时间:
2019-01-12 13:24:18
阅读次数:
181