DJANGO SERVER objects lifecycle

96 views
Skip to first unread message

alexan...@gmail.com

unread,
Aug 9, 2014, 5:13:52 PM8/9/14
to django...@googlegroups.com
Hi 

getting into web development from a C, C++ (non web).
I read and understand quite well the django framework code... but I cannot grasp yet the object life cycle.
I follow the WSGIHandler and BaseHandler, and seemed to me that at every single reuqest, the urls is imported, and in that the admin autodiscover, all models admins etc....
Does everything is created for a request?
Is the python interpreter in NGINX + uwsgi + django launched everytime?

Can anyone give me somelight or direct me some reading on this, I really want to have a good grasp on everything that is happening on the execution model and objects lifetime.

Regards
Alexandre Rua

Collin Anderson

unread,
Aug 9, 2014, 5:20:22 PM8/9/14
to django...@googlegroups.com
Imports are cached, so only the first "import x" or import_module("x")
will run the code and generate a "module" object that gets cached in
sys.modules(?). Using "import" again will just return the same module
object from sys.modules. You can verify with a print statement in a
module that code only gets run once.

The interpreter isn't re-launched every time and we don't guarantee
any startup performance.
Reply all
Reply to author
Forward
0 new messages