Psycopg; How to detect row locking?

Alban Hertroys alban at magproductions.nl
Mon Sep 27 13:40:31 CEST 2004


Good day,

I have a number of threads doing inserts in a table, after which I want 
to do a select. This means that it will occur that the row that I want 
to select is locked (by the DB). In these cases, I believe I receive an 
OperationalError (or is it an InterfaceError?).

Is it possible (and if so - how?) to verify that the exception occured 
because of row locking, so that I can wait and try again?

Or are there better ways to achieve this? I'm not too charmed about 
polling loops that may never end.

I'm using python 2.3 with psycopg 1.1.13 and PostgreSQL 7.4.2.

Regards, Alban Hertroys.



More information about the Python-list mailing list