Skip to content

Instantly share code, notes, and snippets.

@eranrund
Created August 10, 2012 12:20
Show Gist options
  • Save eranrund/3313868 to your computer and use it in GitHub Desktop.
Save eranrund/3313868 to your computer and use it in GitHub Desktop.
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