Python-Requests close http connection

前端 未结 7 1411
既然无缘
既然无缘 2020-11-27 03:14

I was wondering, how do you close a connection with Requests (python-requests.org)?

With httplib it\'s HTTPConnection.close(), but how do I

7条回答
  •  半阙折子戏
    2020-11-27 03:53

    On Requests 1.X, the connection is available on the response object:

    r = requests.post("https://stream.twitter.com/1/statuses/filter.json",
                      data={'track': toTrack}, auth=('username', 'passwd'))
    
    r.connection.close()
    

提交回复
热议问题