def __can_attempt(self, namespace: str, add_attempt=True) -> bool:
can_attempt = False<EOL>if not PyRateLimit.redis_helper:<EOL><INDENT>raise PyRateLimitException("<STR_LIT>")<EOL><DEDENT>connection = PyRateLimit.redis_helper.get_atomic_connection()<EOL>current_time = int(round(time.time() * <NUM_LIT>))<EOL>old_time_limit = current_time - (self.period * <NUM_LIT>)<EOL>connection.zremrangebyscore(namespace, <NUM_LIT:0>, old_time_limit)<EOL>connection.expire(namespace, self.period)<EOL>if add_attempt:<EOL><INDENT>current_count = <NUM_LIT:0><EOL>connection.zadd(namespace, current_time, current_time)<EOL><DEDENT>else:<EOL><INDENT>current_count = <NUM_LIT:1>   <EOL><DEDENT>connection.zcard(namespace)<EOL>redis_result = connection.execute()<EOL>current_count += redis_result[-<NUM_LIT:1>]<EOL>if current_count <= self.limit:<EOL><INDENT>can_attempt = True<EOL><DEDENT>return can_attempt<EOL>
Checks if a namespace is rate limited or not with including/excluding the current call

:param namespace: Rate limiting namespace
:type namespace: str

:param add_attempt: Boolean value indicating if the current call should be considered as an attempt or not
:type add_attempt: bool

:return: Returns true if attempt can go ahead under current rate limiting rules, false otherwise