Esempio n. 1
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()
Esempio n. 2
0
 def test_invalid_pid_fails_silently(self):
     """Ensure passing an invalid pid doesnt not raise exception"""
     pool.remove_session(self.connection, self.session)
Esempio n. 3
0
 def test_invalid_session_fails_silently(self):
     """Ensure that passing an invalid pid doesnt raise an exception"""
     pool.remove_session(self.pid, self.connection)
Esempio n. 4
0
 def test_remove_session_removes_session(self):
     """Ensure a removed session's weakref is not in pool"""
     pool.remove_session(self.pid, self.session)
     self.assertNotIn(weakref.ref(self), pool.Pools[self.pid].sessions)
Esempio n. 5
0
 def test_remove_sets_last_use(self):
     """Ensure that last_use is set for a pool when last session removed"""
     pool.remove_session(self.pid, self.session)
     self.assertEqual(pool.Pools[self.pid].last_use, int(time.time()))