[Twisted-Python] trial and adbapi.ConnectionPool

Jean-Paul Calderone exarkun at divmod.com
Fri Jul 25 08:20:29 EDT 2008


On Fri, 25 Jul 2008 14:50:12 +1000, Tim Allen <tim at commsecure.com.au> wrote:
>In the projects I'm working on at the moment, we're using
>t.e.adbapi.ConnectionPool wrapping psycopg2 to handle connections to a
>PostgreSQL database. The setUp method of our unit-tests drops and
>recreates the database each time, and we've discovered that
>intermittently tests will fail because a previous test is still
>connected to the database when the subsequent test runs. Annoyingly, it
>happens on some machines and not others.

The problem may have something to do with the implementation of
adbapi.Connection.close:

    def close(self):
        # The way adbapi works right now means that closing a connection is
        # a really bad thing  as it leaves a dead connection associated with
        # a thread in the thread pool.
        # Really, I think closing a pooled connection should return it to the
        # pool but that's handled by the runWithConnection method already so,
        # rather than upsetting anyone by raising an exception, let's ignore
        # the request
        pass

which seems somewhat short of ideal to me.

Jean-Paul




More information about the Twisted-Python mailing list