title: Python exception: ConnectionError 10054 An existing connection was forcibly closed by the remote host
body: <p>I don't have enough reputation yet to comment on another post so I'll ask it here. I am getting the "ConnectionError 10054 An existing connection was forcibly closed by the remote host" while doing a 'requests.get'. Now, I read this code on the other post but not sure if it is complete; can you please edit it so that it keeps retrying my 'requests.get' when the error comes up then exit of course when my 'requests.get' is successful. Thank you</p>
  
  <pre><code>import socket
  
  retry_count = 5  # this is configured somewhere
  
  for retries in range(retry_count):
      try:
          data1 = requests.get(url)
          return True
      except (error_reply, error_perm, error_temp):
          return False
      except socket.gaierror, e:
          if e.errno != 10054:
              return False
          reconnect()
  return False
  </code></pre>
  
  <p>Getting error;
      return True
      ^
  SyntaxError: 'return' outside function</p>