I'm building an application using Flask running locally on the Google App Engine SDK. For some reason my entrypoint, being main.py
, is only initiated once.
main.py
:
from bootstrap import myapp
app = myapp.bootstrap()
print "I'm bootstrapping"
if __name__ == '__main__':
app.run()
myapp/bootstrap.py
:
Returns an instance of MyApp.Application
myapp/Application.py
:
Extends Flask, registers the routes,...
Console output:
INFO 2016-10-24 20:02:10,807 module.py:788] default: "GET / HTTP/1.1" 200 12
INFO 2016-10-24 20:02:11,595 module.py:788] default: "GET / HTTP/1.1" 200 12
INFO 2016-10-24 20:02:20,137 module.py:402] [default] Detected file changes:
./main.py
I'm bootstrapping
INFO 2016-10-24 20:02:22,199 module.py:788] default: "GET / HTTP/1.1" 200 12
INFO 2016-10-24 20:02:28,206 module.py:788] default: "GET / HTTP/1.1" 200 12
The request is handled correctly and the route functions are called every time. main.py
on the other hand is only loaded once and only reloaded when a file has changed (as you can see from the logs). It seems like the whole application is initiated once and cached.
Also: Values you assign within a route-method to the application instance are also 'cached' and available in further requests (which seems like weird behaviour).
Is this behaviour normal in Python? Or is this behaviour specific to Google App Engine?