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()
def test_invalid_pid_fails_silently(self): """Ensure passing an invalid pid doesnt not raise exception""" pool.remove_session(self.connection, self.session)
def test_invalid_session_fails_silently(self): """Ensure that passing an invalid pid doesnt raise an exception""" pool.remove_session(self.pid, self.connection)
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)
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()))