Esempio n. 1
0
    def close(self):
        """Explicitly close the connection and remove it from the connection
        pool if pooling is enabled.

        :raises: AssertionError

        """
        if not self._conn:
            raise AssertionError('Connection not open')

        if self._use_pool:
            pool.remove_connection(self.pid, self._conn)

        # Close the connection
        self._conn.close()
        self._conn, self._cursor = None, None
Esempio n. 2
0
 def test_invalid_pid_fails_silently(self):
     """Ensure passing an invalid pid doesnt not raise exception"""
     pool.remove_connection(self.connection, self)
Esempio n. 3
0
 def test_invalid_connection_fails_silently(self):
     """Ensure that passing an invalid pid doesnt raise an exception"""
     pool.remove_connection(self.pid, self)
Esempio n. 4
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)
Esempio n. 5
0
 def test_remove_connection_removes_connection(self):
     """Ensure a removed connection is not in pool"""
     pool.remove_connection(self.pid, self.connection)
     self.assertNotIn(self.connection, pool.Pools[self.pid].connections)