标签:gevent
import time
import gevent
from gevent.threadpool import ThreadPool
pool = ThreadPool(6)
start = time.time()
for _ in range(12):
pool.spawn(time.sleep, 1)
gevent.wait()
delay = time.time() - start
print(‘Running "time.sleep(1)" 4 times with 3 threads. Should take about 2 seconds: %.3fs‘ % delay)
本文出自 “大荒芜经” 博客,请务必保留此出处http://2892931976.blog.51cto.com/5396534/1867706
标签:gevent
原文地址:http://2892931976.blog.51cto.com/5396534/1867706