python - GAE Webapp: the cost of importing a bunch of request handlers -
my python gae app's central application file looks this:
import webapp2 import homepage import user_auth import user_confirm import admin_user import admin_config import config app = webapp2.wsgiapplication([ (user_auth.get_login_url(), user_auth.loginhandler), (user_auth.get_logout_url(), user_auth.logouthandler), ("/user/confirm", user_confirm.userconfirmhandler), ("/admin/config", admin_config.adminconfighandler), ("/admin/user/add", admin_user.adminadduserhandler), ("/admin/user", admin_user.adminuserhandler), ("/", homepage.homepagehandler), ], debug=true) as can see, must import bunch of request handlers, each request, 1 of them used, other imports useless!
that's big waste of memory , performance because unnecessary imports import other things on own. google app engine have "caching" mechanism or makes these unnecessary imports negligible? think not.
how can avoid them? haven't found out way import 1 request handler per request. if put routing app.yaml, work way want, makes things complex because must write app = webapp2.wsgiapplication(... every request handler file , repeat boring urls twice (both in python file , in app.yaml).
found way here, built webapp2 http://webapp-improved.appspot.com/guide/routing.html#lazy-handlers
Comments
Post a Comment