Re: Closing connection

Oleg Broytman <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
On Wed, Feb 01, 2012 at 03:28:30PM +0100, Daniel Dehennin wrote:
>             Rebuildd().sqlconnection.close()

   Aha, got it. You've stumbled upon a subtle bug in SQLiteConnection.
SQLiteConnection uses a different (from its parent class DBAPI)
implementation of .getConnection() and maintain its own pool -
._threadPool along with DBAPI._pool. But it doesn't clear the pool on
.close().

   The quick-and-dirty solution for you is to clear the pool yourself:

            Rebuildd().sqlconnection.close()
            Rebuildd().sqlconnection._threadPool = {}

   I'll add a proper .close() to SQLiteConnection.

> 	    sqlobject.sqlhub.processConnection = Rebuildd().sqlconnection

   You preserve an old SQLiteConnection, so you don't need the
following:

> 	    sqlobject.dbconnection.TheURIOpener.cachedURIs={}

   The workaround is for the case when you want to create a new
SQLiteConnection like this:

            Rebuildd().sqlconnection = connectionForURI(...)

   And, BTW, this

>             os.unlink("/tmp/rebuildd-tests.db")

   is just

            Rebuildd().sqlconnection.dropDatabase()

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.