Come profilo codice Python sotto Google App Engine runtimepython27?Come al profilo Google App Engine runtime python27 (non python)
Nel runtime pitone è stato fatto da questo codice - python runtime:
from google.appengine.ext import webapp
class PageHandler(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, WebApp World!')
def real_main():
application = webapp.WSGIApplication([('/', PageHandler)], debug=True)
run_wsgi_app(application)
def profile_main():
# This is the main function for profiling
# We've renamed our original main() above to real_main()
import cProfile, pstats, StringIO
prof = cProfile.Profile()
prof = prof.runctx('real_main()', globals(), locals())
stream = StringIO.StringIO()
stats = pstats.Stats(prof, stream=stream)
stats.sort_stats('cumulative')
logging.info("Profile data:\n%s", stream.getvalue())
if __name__ == "__main__":
profile_main()
Nel runtime python27 si deve essere fatto in modo diverso in quanto non v'è alcuna principali chiamate - come fare la stessa cosa - Voglio passare a python27 ma non senza profilazione. Come collegare il profiler in python27 - python27 runtime?
import webapp2
class PageHandler(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, WebApp World!')
app = webapp2.WSGIApplication([('/', PageHandler)])
'è ancora possibile specificare gestori di script CGI in app.yaml.' Se Capisco correttamente, puoi ancora usare i vecchi metodi se non hai bisogno di 'richieste simultanee' – Dikei
Probabilmente ma l'uso di app.yaml non va bene dato che vuoi testare senza cgi e non modificare app.yaml ogni test (lento) . – Chameleon