Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created May 13, 2011 16:51
Show Gist options
  • Save gregglind/970871 to your computer and use it in GitHub Desktop.
Save gregglind/970871 to your computer and use it in GitHub Desktop.
some broken threadpool stuff
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