def test_threadCount(self): """ The reactor associated with a L{ConnectionPool} will have its maximum thread count adjusted when L{ConnectionPool.startService} is called, to accomodate for L{ConnectionPool.maxConnections} additional threads. Stopping the service should restore it to its original value, so that a repeatedly re-started L{ConnectionPool} will not cause the thread ceiling to grow without bound. """ defaultMax = 27 connsMax = 45 combinedMax = defaultMax + connsMax pool = ConnectionPool(None, maxConnections=connsMax) pool.reactor = ClockWithThreads() threadpool = pool.reactor.getThreadPool() pool.reactor.suggestThreadPoolSize(defaultMax) self.assertEquals(threadpool.max, defaultMax) pool.startService() self.assertEquals(threadpool.max, combinedMax) justChecking = [] pool.stopService().addCallback(justChecking.append) # No SQL run, so no threads started, so this deferred should fire # immediately. If not, we're in big trouble, so sanity check. self.assertEquals(justChecking, [None]) self.assertEquals(threadpool.max, defaultMax)
def test_isRunning(self): """ L{ConnectionPool.startService} should set its C{running} attribute to true. """ pool = ConnectionPool(None) pool.reactor = ClockWithThreads() self.assertEquals(pool.running, False) pool.startService() self.assertEquals(pool.running, True)