Skip to content

Instantly share code, notes, and snippets.

@rsyring
Created February 16, 2011 02:05
Show Gist options
  • Save rsyring/828716 to your computer and use it in GitHub Desktop.
Save rsyring/828716 to your computer and use it in GitHub Desktop.
import isapi_wsgi
from fakeecb import FakeECB
from random import random
import time
from profiledec import profile
def wsgiapp(environ, start_response):
'''Simple app as per PEP 333'''
status = '200 OK'
#time.sleep(.1)
start_response(status, [('Content-type', 'text/plain')])
return ['Hello world from isapi! %s' % random() ]
han = isapi_wsgi.ISAPISimpleHandler(wsgiapp)
def simreq():
han.HttpExtensionProc(FakeECB())
@profile(stderr=False, fileName=r"profiler_output.txt")
def dotest():
for i in xrange(0, 10000):
simreq()
print 'done testing'
dotest()
from StringIO import StringIO
class FakeECB:
def __init__(self):
self._stdout = StringIO()
self.AvailableBytes = 0
self.vars = {
"REQUEST_METHOD":"GET",
"SCRIPT_NAME":"/",
"PATH_INFO":"/",
"QUERY_STRING":"",
"CONTENT_TYPE":"",
"CONTENT_LENGTH":"0",
"SERVER_NAME":"localhost",
"SERVER_PORT":"80",
"SERVER_PROTOCOL":"HTTP/1.0",
"ALL_HTTP":"",
'APPL_MD_PATH': '/LM/W3SVC/1/ROOT',
'REMOTE_ADDR': '127.0.0.1',
}
def WriteClient(self, s):
self._stdout.write(s)
write = WriteClient
def close(self):
pass
def GetServerVariable(self, cgivar):
return self.vars[cgivar]
def SendResponseHeaders(self, status, headers, ka):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment