Created
December 18, 2012 22:19
-
-
Save slingamn/4332611 to your computer and use it in GitHub Desktop.
old leak test from kennethreitz/requests#520
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc, os, subprocess, requests | |
gc.disable() # Just to make sure - I have seen this with gc enabled | |
for x in range(20): | |
requests.head("http://www.google.com/") | |
print "Open sockets after 20 head requests:" | |
pid = os.getpid() | |
subprocess.call("lsof -p%d -a -iTCP" % (pid,), shell=True) | |
gcresult = gc.collect() | |
print "Garbage collection result: %s" % (gcresult,) | |
print "Open sockets after garbage collection:" | |
subprocess.call("lsof -p%d -a -iTCP" % (pid,), shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment