iro/model/pool.py
branchdevel
changeset 132 80a334e2aae7
parent 117 351a02310dd8
child 151 ff8448fb07e7
--- a/iro/model/pool.py	Mon Jan 30 23:28:14 2012 +0100
+++ b/iro/model/pool.py	Mon Feb 06 12:31:47 2012 +0100
@@ -1,25 +1,18 @@
 from decorator import decorator
-from twisted.python.threadpool import ThreadPool
-from twisted.internet import threads
-
-POOL_SIZE=5     #how many threads should the db connector pool should have
 
 class Data:
     def __init__(self):
-        self.pool =  ThreadPool(minthreads=1, maxthreads=POOL_SIZE, name='database')
-        self.reactor = None
+        self.pool =  None
 
 data = Data()
 #a valid dbDefer decorator
 
-def startPool(reactor): 
-    data.pool.start()
-    data.reactor = reactor
-    data.reactor.addSystemEventTrigger('before', 'shutdown', data.pool.stop)
+def setPool(pool): 
+    data.pool = pool
 
 @decorator
 def runInDBPool(f,*args,**kwargs):
     """Decorator to run DB queries in Twisted's thread pool"""
-    return threads.deferToThreadPool(data.reactor, data.pool, f, *args, **kwargs)
+    return data.pool.run(f, *args, **kwargs)