如何在Google App Engine运行时python27下分析python 代码?
在运行时python它是由这个代码完成的 - python 运行时:
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()
在运行时python27必须以不同的方式完成,因为没有主要调用 - 如何做同样的事情 - 我想切换到 python27 但不是没有分析。如何在python27 - python27 运行时附加探查器?
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)])