在程序发生阻塞的时候(读写磁盘,读写文件,网络IO,HTTP请求)
携程库原理
# 原生python方法
f = open('./test','r')
f.read()
# 协程提供改写的方法
def read():
进行操作系统调用 read 非阻塞调用
yield
import eventlet
eventlet.monkey_patch() # 将原生python方法全部换成协程方法
在程序发生阻塞的时候(读写磁盘,读写文件,网络IO,HTTP请求)
携程库原理
# 原生python方法
f = open('./test','r')
f.read()
# 协程提供改写的方法
def read():
进行操作系统调用 read 非阻塞调用
yield
import eventlet
eventlet.monkey_patch() # 将原生python方法全部换成协程方法