Skip to content Skip to sidebar Skip to footer

Where Is The Best Place To Put One-time And Every-time Code In GAE/Python?

I am new to Google App Engine and Python. I am having trouble understanding some basic questions about Python apps running on Google App Engine. If I want code to execute: On ever

Solution 1:

Question Number 1:

Some web frameworks (Django, KAY, etc) have a concept of Middleware. You can create your own middleware that will execute on every request and handle this sort of information (see: https://docs.djangoproject.com/en/dev/topics/http/middleware/)

Question Number 2:

Warmup requests (see: https://developers.google.com/appengine/docs/python/config/appconfig#Warmup_Requests)

Though since warmup requests are not guaranteed to run, you can put a global variable to let the instance know if it was "initialized" and check that variable on every page load (this will be cheap since the variable will live in memory and exist between requests). If it is not set, then run through your "warmup" as needed.


Post a Comment for "Where Is The Best Place To Put One-time And Every-time Code In GAE/Python?"