<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def allowed(self):
        '''
        Check to see if the pop request is allowed

        @return: True means the maximum was not been reached for the current
            time window, thus allowing what ever operation follows
        '''
        # Expire old keys (hits)
        expires = time.time() - self.window
        self.redis_conn.zremrangebyscore(self.window_key, '-inf', expires)

        # check if we are hitting too fast for moderation
        if self.moderation:
            with self.redis_conn.pipeline() as pipe:
                try:
                    pipe.watch(self.moderate_key)  # ---- LOCK
                    # from this point onward if no errors are raised we
                    # successfully incremented the counter

                    curr_time = time.time()
                    if self.is_moderated(curr_time, pipe) and not \
                            self.check_elastic():
                        return False

                    # passed the moderation limit, now check time window
                    # If we have less keys than max, update out moderate key
                    if self.test_hits():
                        # this is a valid transaction, set the new time
                        pipe.multi()
                        pipe.set(name=self.moderate_key,
                                 value=str(curr_time),
                                 ex=int(self.window * 2))
                        pipe.execute()
                        return True

                except WatchError:
                    # watch was changed, another thread just incremented
                    # the value
                    return False

        # If we currently have more keys than max,
        # then limit the action
        else:
            return self.test_hits()

        return False