Psycopg and threads problem

Cliff Wells clifford.wells at
Mon Sep 20 16:04:34 CEST 2004

On Mon, 2004-09-20 at 14:43 +0200, Alban Hertroys wrote:
> Hello,
> I'm using psycopg to insert records in a number of threads. After the 
> threads finish, another thread runs to collect the inserted data. Now, 
> my problem is that psycopg let's my threads end before the inserts 
> actually took place, resulting in my collecting thread finding no 
> records... They are inserted after it checks.
> Is there a way to tell psycopg or python to wait until the insert took 
> place?

I believe turning autocommit on in the connection would achieve this (at
the expense of performance and transaction support).  You could also add
a "commit" SQL statement to each thread.

Why not have the threads notify the other threads that it's okay to
start working?  If you have to wait until the data is completely
inserted anyway, have your final thread perform the "commit" and then
set a threading.Event or somesuch .


Cliff Wells <clifford.wells at>

More information about the Python-list mailing list