title: Why Python http request creates TIME_WAIT connections?
body: <p>I have this simple code, which connects with an external server. I call this function 100s of time a minute. And after a while I'm getting system lacked sufficient buffer exception. When I viewed the connections using TCPView it shows hundreds of connections to external server in TIME_WAIT status.</p>
  
  <ol>
  <li>Why this is happening?</li>
  <li><p>Is python request module not suitable if I have to send 100s of requests, then what should I do?</p>
  
  <pre><code>  def sendGetRequest(self, url, payload):
  
          success = True
          url = self.generateUrl(url)
          result = requests.get(url, params=urllib.parse.urlencode(payload))
          code = result.status_code
          text = result.text
  
          if code &lt; 200 or code &gt;= 300:
              success = False
  
          result.close()
          return success, code, text
  </code></pre></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/D9NOD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D9NOD.png" alt="enter image description here"></a></p>