#携程,(微线程)
# import greenlet
# gr1 = greenlet(test1)
# gr1.switch()
import gevent
from gevent import monkey;monkey.patch_all()#类似开启协程
#gevent调用的greenlet
import requests
def func(url):
print("GET:",url)
response = requests.get(url)
data = response.text
print(len(data))
gevent.joinall([
gevent.spawn(func,"https://www.baidu.com"),
gevent.spawn(func,"https://weibo.com"),
gevent.spawn(func,"http://www.qq.com/")
])
转载于:https://www.cnblogs.com/currynashinians000/p/8744439.html