Lazy loading database connection

56 views
Skip to first unread message

Andrey Kuzmin

unread,
Apr 23, 2012, 12:04:46 PM4/23/12
to we...@googlegroups.com
I've got a problem: if database isn't running then the error is raised during setting up database wrapper.
This blocks the start of the whole app. 

Is there any way to raise this error when querying database during processing of http requests, with attempts to reconnect on every db query if database connection hasn't been established?

Scott Gelin

unread,
Apr 23, 2012, 12:08:17 PM4/23/12
to we...@googlegroups.com
Would it make sense to test the DB connection before establishing DB as your session storage and if it is down use disk store instead?

--
You received this message because you are subscribed to the Google Groups "web.py" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webpy/-/Cg0k9iWiI2sJ.
To post to this group, send email to we...@googlegroups.com.
To unsubscribe from this group, send email to webpy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.

Andrey Kuzmin

unread,
Apr 23, 2012, 1:50:03 PM4/23/12
to we...@googlegroups.com
I'm not using db only for session storage. I use it to query data, and for search purposes (talk to Sphinx Search via SQL protocol).

Sometimes when server gets rebooted, my app doesn't start because of database — so I have to restart uwsgi process manually (I deploy my app using nginx+uwsgi).

Andrey Kuzmin

unread,
Apr 23, 2012, 2:07:49 PM4/23/12
to we...@googlegroups.com
I'm sorry, it seems that mistake is in my subclass of db driver to be used with sphinx search, because app runs when mysql server is offline, but doesn't start when sphinx is off.

Andrey Kuzmin

unread,
Apr 23, 2012, 2:45:34 PM4/23/12
to we...@googlegroups.com
Here is how to have Sphinx Search database wrapper for web.py: https://gist.github.com/2472971
Reply all
Reply to author
Forward
0 new messages