michael bayer
mike_mp at zzzcomputing.com
Sat Nov 27 13:22:13 EST 2004
The database API http://www.python.org/peps/pep-0249.html refers to a module global called "threadsafety" which is an integer defining at what level can multiple threads share a database resource, for a given database connection library. I would note that the approach of keeping the connection object as a global variable, using a new cursor within each query requires this to be value 2 (threads can share the module and connections) or 3 (threads can share the module, connections, and cursors). if you can guarantee that your application will only run with a non-threaded apache (prefork MPM), then you dont have to worry about threading, but I generally like to write an application such that it can run in as many environments as possible. On Nov 26, 2004, at 5:21 PM, Nick wrote: > That was me. I would recommend keeping the global in the module > namespace that contains your handler code. You can check every request > to see if you're still connected. Also, see the FAQ for a more complex > setup: > > http://modpython.org/FAQ/faqw.py?req=show&file=faq03.003.htp > > Nick > > On Fri, 2004-11-26 at 14:39 -0700, Trevor West wrote: >> When I was asking about my database problems. Someone mentioned to me >> that they kept a single global database connection and just pulled >> cursers off that. And while I know how to do that in the context of a >> thick client add (we build a big app with wxPython), I'm not sure how >> to >> keep globals in apache other than using the session. I've seen lots of >> examples on the web but none of it seems to make much sense... >> >> Cheers >> >> Trevor >> _______________________________________________ >> Mod_python mailing list >> Mod_python at modpython.org >> http://mailman.modpython.org/mailman/listinfo/mod_python > -- > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|