Answer the question
In order to leave comments, you need to log in
How to declare two Python variables in one class?
Good day to all, please help me to understand the code.
import task
class TooManyRequests(Exception):
"""Too many requests"""
@task(
rate_limit='10/s',
autoretry_for=(ConnectTimeout, TooManyRequests,),
retry_backoff=True)
def api(*args, **kwargs):
r = requests.get('placeholder-external-api')
if r.status_code == 429:
raise TooManyRequests()
Выдает ошибку
in <module>
autoretry_for=(ConnectTimeout, TooManyRequests,),
NameError: name 'ConnectTimeout' is not defined
Answer the question
In order to leave comments, you need to log in
You didn't import ConnectTimeout from some package, most likely from requests.exceptions. https://docs.python-requests.org/en/master/_module...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question