Commit 997e5248 authored by Denis Bilenko's avatar Denis Bilenko

add examples/threadpool.py

parent 7a910e29
import time
import gevent
from gevent.threadpool import ThreadPool
pool = ThreadPool(3)
start = time.time()
for _ in xrange(4):
pool.spawn(time.sleep, 1)
gevent.run()
delay = time.time() - start
print 'Running "time.sleep(1)" 4 times with 3 threads. Should take about 2 seconds: %.3fs' % delay
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment