Open kgaughan opened 12 years ago
Some kind of threadlocal storage would be ideal, but we need to trap when the thread exits.
Getting there. Punting the issue with threads exiting to weak references. ThreadAffinePool needs testing though.
Turns out the sqlite3 driver doesn't like weak references being used with its connections. Weak. I've switched to using strong references for it. This does not make me happy. Also added DummyPool, which is specifically meant for type 0 drivers where it forces a single connection at a time, but will allow multiple connections with more capable drivers.
ThreadAffinePool
has been nixed for the moment: it has race conditions.
When using DummyPool
with the sqlite3
driver module and waitress, I'm getting "ProgrammingError: Cannot operate on a closed database" as an exception. My guess is that this is some kind of race condition, and it may affect Pool
in some way that I don't know about (even though it appears to work just fine).
Still can't get type 1 driver support right, so I'm removing it and maybe creating a separate branch.
The reason for this is SQLite support. I'm not sure how exactly I'll end up implementing this as the thread affinity involved is a touch more awkward to deal with than with type 2 and type 3 drivers, which the existing connection pool handles just fine.