from diesel import quickstart, sleep, quickstop
from diesel.util.pool import ThreadPool
import random

def handle_it(i):
    print 'S', i
    sleep(random.random())
    print 'E', i

def c():
    for x in xrange(0, 20):
        yield x

make_it = c().next

def stop_it():
    quickstop()

threads = ThreadPool(10, handle_it, make_it, stop_it)

quickstart(threads)

from diesel import quickstart, sleep
from diesel.util.pool import ThreadPool
from diesel.protocols.http import HttpClient, HttpHeaders
import random

def handle_it(i):
    print 'S', i
    sleep(random.random())
    print 'E', i

def c():
    for x in xrange(0, 20):
        yield x

make_it = c().next

threads = ThreadPool(10, handle_it, make_it)

quickstart(threads)

--- 
+++ 
@@ -1,6 +1,5 @@
-from diesel import quickstart, sleep
+from diesel import quickstart, sleep, quickstop
 from diesel.util.pool import ThreadPool
-from diesel.protocols.http import HttpClient, HttpHeaders
 import random
 
 def handle_it(i):
@@ -14,6 +13,9 @@
 
 make_it = c().next
 
-threads = ThreadPool(10, handle_it, make_it)
+def stop_it():
+    quickstop()
+
+threads = ThreadPool(10, handle_it, make_it, stop_it)
 
 quickstart(threads)
Clean it up with a finalizer.
