예제 #1
0
 def test_idle_connections_closed(self):
     """Ensure a connection in an idle pool is closed"""
     pool.Pools[self.pid] = \
         pool.Pools[self.pid]._replace(sessions=set(),
                                       last_use=int(time.time()-pool.TTL-2))
     pool.clean_pools()
     self.cclose.assert_called_once_with()
예제 #2
0
 def test_idle_pool_removed(self):
     """Ensure an idle pool is removed"""
     pool.Pools[self.pid] = \
         pool.Pools[self.pid]._replace(sessions=set(),
                                       last_use=int(time.time()-pool.TTL-2))
     pool.clean_pools()
     self.assertNotIn(self.pid, pool.Pools)
예제 #3
0
    def _cleanup(self):
        """Remove the connection from the stack, closing out the cursor"""
        if self._cursor:
            self._cursor.close()
            self._cursor = None

        if self._conn:
            self._conn = None

        if self._use_pool:
            pool.remove_session(self.pid, self)
            pool.clean_pools()
예제 #4
0
 def test_dead_weakref_removed_but_pool_not_removed(self):
     """Ensure a pool with no remaining sessions is not removed"""
     del self.session
     pool.clean_pools()
     self.assertIn(self.pid, pool.Pools)
예제 #5
0
 def test_dead_weakref_removed(self):
     """Ensure a deleted session obj is not in the pool"""
     del self.session
     pool.clean_pools()
     self.assertEqual(len(pool.Pools[self.pid].sessions), 0)
예제 #6
0
 def test_empty_pool_removed(self):
     """Ensure a removed connection is not in pool"""
     pool.remove_connection(self.pid, self.connection)
     pool.clean_pools()
     self.assertNotIn(self.pid, pool.Pools)