#104 cacheing uri in connectionForURI() stomps on connections

open
nobody
General (125)
5
2013-01-18
2005-08-04
Anonymous
No

If you are using SQLObject where you have one
connection per thread , the cacheing of the uri in
connectionForURI stomps on the connections.

This happens for me when I am using SQLObject with
CherryPy and SQLite. On each thread start up, I create
a connectionHub object for that thread. If I use the
connectionForURI method, the connections get stomped
on, and I get tracebacks saying that the cursor is
being accessed by a thread other than the one that
created it. If I bypass that and use the deprecated
method of creating the connection directly with
SQLiteConnection(), it works fine.

If we are going to cache the uri's (Is there a good
reason to do this? Shouldn't a connection only be
generated once?), we need to have a method of sending a
thread id or something similar to the connectionForURI
method so that it gets cached correctly.

I would suspect that this will also cause major
problems for anyone who is trying to use one connection
per thread (I think you still need to do this with MySQL).

If you have any questions, you can reach me at
cthier@gmail.com

You can also read the following thread for more
information:
http://groups-beta.google.com/group/cherrypy-users/browse_thread/thread/1e979bb1f766f0f3/8dfdba9cf489fa63#8dfdba9cf489fa63

Discussion