title: Using Python decorators to retry request
body: <p>I have multiple functions in my script which does a REST API api requests.As i need to handle the error scenarios i have put a retry mechanism as below.</p>
  
  <pre><code>no_of_retries = 3
  def check_status():
      for i in range(0,no_of_retries):
          url = "http://something/something"
          try:
              result = requests.get(url, auth=HTTPBasicAuth(COMMON_USERNAME, COMMON_PASSWORD)).json()
              if 'error' not in result:
                  return result
              else:
                  continue
          except Exception as e:
              continue
      return None
  </code></pre>
  
  <p>I have several different methods which does similar operation. How can we do it better way to avoid duplication may be using decorators.</p>