Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
demonstrates python-requests socket leak
import requests
reqsess = requests.session()
try:
r = reqsess.get(r'http://www.mouser.com/Search/Refine.aspx?Keyword=test')
d = r.text
finally:
reqsess.close()
print 'done'
import time
time.sleep(10) # Have a look at netstat during this time and see a leftover socket in CLOSE_WAIT state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment