Psycopg and threads problem

Istvan Albert ialbert at mailblocks.com
Mon Sep 20 18:16:50 CEST 2004


Alban Hertroys wrote:

> I can't commit until all the data has been inserted and combined. The 
> commit shouldn't happen until the end of the main thread is reached.

If you don't commit the inserts you cannot combine them (because they are
not visible) in a different database connection. I think you should
have a commit at the end of your insert threads. That way
when all the inserts are finished the data will be available
for the combine thread.

I might be wrong here but I think all this confusion arises because
psycopg pools database connections (which is a good thing, it speeds
up access). But then even when you seemingly open a new connection
you might be just reusing a db connection from the pool that was
started (and kept alive) before the inserts took place.

Istvan.



More information about the Python-list mailing list