I got funny exceptions in the _connection_notinuse
function of dbpool.py. My hunch was that because I
instantiated many threads at the same time, all using
the same connection, they maybe all entering this
function at the same time. _make_available has a lock,
but the rest of the stuff in _connection_notinuse isn't
inside a lock. so I added another lock
(_lock_not_in_use) which I aquire inside the
_connection_notinuse function and release at the end.
This got rid of the errors. Haven't tested extensively,
but things seem to work fine now. I'm not a python (and
especially not a threading) guru yet, so I'm not sure
if this is the most efficient fix, but it does at least
help proove my theory, I think.
(by the way - great module. Exactly what I was looking
for. Saved me a lot of work)
--- dbpool.py 2002-07-03 18:50:38.000000000 +0200
+++ jonpy-0.06/jon/dbpool.py 2004-09-27
12:30:04.000000000 +0200
@@ -10,6 +10,7 @@
_dbmod = None
_lock = _thread.allocate_lock()
+_lock_not_in_use = _thread.allocate_lock()
_refs = {}
@@ -62,6 +63,8 @@
def _connection_notinuse(ref):
+ _lock_not_in_use.acquire()
+ try:
inner = _refs[ref]
del _refs[ref]
inner._cursorref = None
@@ -71,6 +74,8 @@
if _make_available is not None:
_make_available(_Connection(inner))
+ finally:
+ _lock_not_in_use.release()
class _Connection:
def __init__(self, inner, *args, **kwargs):
Logged In: YES
user_id=1129002
oops. forgot to log in.