python - Apache/ mod wsgi if __name__ == '__main__' equivalent -
to use leveldb (python database) need database loaded when start server , not each time user uses website.
previously used web.py , if __name__ == '__main__'
statement make happen. once switched apache __name__
variable modwsgi_....
.
can provide me alternative work apache , modwsgi please?
the value of __name__
of form _mod_wsgi_?????
, use:
if __name__.startswith('_mod_wsgi_'): ...
better still, use wsgi script file distinct else used mod_wsgi. create app.wsgi
file imports application object elsewhere. don't need check , can loading @ global scope.
just make sure using daemon mode in either case, in embedded mode wsgi script file technically loaded more once in life of process if modification time changed. in daemon mode doesn't happen changing wsgi script file cause whole process shutdown , reloaded instead.
btw, how know if mod_wsgi running documented in:
Comments
Post a Comment