-
-
Save slingamn/955bfeaded8099b1a99f to your computer and use it in GitHub Desktop.
This file contains 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 httplib | |
class Instrumented(httplib.HTTPResponse): | |
def close(self): | |
print "close intercepted!!!!!" | |
import traceback | |
traceback.print_stack() | |
if self.fp: | |
self.fp.close() | |
self.fp = None | |
httplib.HTTPResponse = Instrumented | |
httplib.HTTPConnection.response_class = Instrumented | |
import requests | |
import os | |
import subprocess | |
pid = os.getpid() | |
reqsess = requests.session() | |
try: | |
#r = reqsess.get(r'http://www.mouser.com/Search/Refine.aspx?Keyword=test') | |
r = reqsess.get(r'http://www.google.in/') | |
d = r.text | |
finally: | |
reqsess.close() | |
print "_fp is", r.history[0].raw._fp | |
print "_fp.fp is", r.history[0].raw._fp.fp | |
print 'done, calling lsof' | |
subprocess.call("lsof -p%d -a -iTCP" % (pid,), shell=True) | |
print 'done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment