title: Python retry using the tenacity module
body: <p>I'm having having difficulty getting the <a href="https://github.com/jd/tenacity" rel="nofollow noreferrer">tenacity library</a> to work as expected. The retry in the following test doesn't trigger at all. I would expect a retry every 5 seconds and for the log file to reflect the retry attempts.</p>
  
  <pre><code>import paramiko
  import tenacity
  from configparser import RawConfigParser
  import logging
  
  def main():
      parser = RawConfigParser()
      parser.read('config.ini')
      HOST = parser['SSH']['host']
      PORT = parser['SSH']['port']
      USER = parser['SSH']['user']
      LOG_LEVEL = parser['Logging']['level']
      LOG_FILE = parser['Files']['log_file']
      LOG_FORMAT = parser['Logging']['format']
  
      with open(LOG_FILE, "a") as f:
          logging.basicConfig(filename=LOG_FILE,level=LOG_LEVEL,format=LOG_FORMAT)
          logging.info("******Started logging******")
  
      client = paramiko.SSHClient()
      client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  
      @tenacity.retry(wait=tenacity.wait_fixed(5))
      def connect():
          try:
              client.connect(HOST, int(PORT), USER)
              logging.info("Successful connection to remote server")
          except Exception:
              logging.error("Cannot connect to remote server")
  
      connect()
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>The log file spits this out:</p>
  
  <pre><code>&gt; 2017-11-04 19:55:20,695 ******Started logging******
  &gt; 2017-11-04 19:55:20,695 Cannot connect to remote server
  </code></pre>