Cómo perfil código Python bajo Google App Engine tiempo de ejecución python27?al perfil de Google App Engine python27 tiempo de ejecución (no pitón)
En tiempo de ejecución pitón que fue hecho por el código - 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()
En tiempo de ejecución python27 se tiene que ser hecho de manera diferente ya que no hay principales llamadas - cómo hacer la misma cosa - Quiero cambiar a python27 pero no sin perfiles. Cómo adjuntar el generador de perfiles en 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)])
'aún puede especificar gestores de script CGI en app.yaml.' Si Entiendo correctamente, puede seguir utilizando las antiguas formas si no necesita 'solicitudes simultáneas' – Dikei
Probablemente, pero el uso de app.yaml no es bueno, ya que quiere probar sin cgi y no editar app.yaml cada prueba (es lento) . – Chameleon