def get_next_id(self):
        try:
            query = {'_id': 'last_id'}
            update = {'$inc': {'id': 1}}
            fn = self.db.internal.find_and_modify
            row = fn(query, update, upsert=True, new=True)
        except Exception as e:
            raise DatabaseException(e)
        return row['id']
def _handle_sigint_if_enabled(self, signum, _frame):
        with self._ignore_sigint_lock:
            self._check_sigint_gate_is_correct()
            threads_ignoring_sigint = self._threads_ignoring_sigint
            ignoring_sigint_v2_engine = self._ignoring_sigint_v2_engine
        if threads_ignoring_sigint == 0 and not ignoring_sigint_v2_engine:
            self.handle_sigint(signum, _frame)