Created
May 13, 2011 16:51
-
-
Save gregglind/970871 to your computer and use it in GitHub Desktop.
some broken threadpool stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from paste.httpserver import ThreadPool | |
pool = ThreadPool(5) | |
import random | |
import time | |
def do_work(t): | |
print 'about to sleep for %s sec' % (t,) | |
time.sleep(t) | |
print 'slept for %s' %(t) | |
return (t, True) | |
source = [random.random() for x in range(50)] | |
#def join_all(queue): | |
# if queue.qsize()>0: | |
# for x in queue: | |
# x.join(2) | |
def go(): | |
print 'about to block' | |
for item in source: | |
print item | |
pool.add_task(lambda: do_work(item)) | |
#join_all(pool.queue) | |
#print 'done' | |
return pool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment