In fact, my code had a bug in it -- I was both rolling back and releasing the savepoint (via a finally). Sorry about that.
For the record this *does* work: you can use savepoints and row-level locking for synchronization between different processes, as you would hope.... Thanks. On Dec 18, 2:03 am, shaunc <sh...@cuttshome.net> wrote: > Can anyone help me with the following point? > > Does django keep internal state when psycopg throws a > OperationalError, and how do I clear it? > > The situation is this: I have external processes writing into a django/ > postgres database. To avoid using semaphors, etc, I'm trying to use a > row level lock and the "savepoint" mechanism to make sure a particular > process is the only one modifying a certain set of table rows. > > When another process has beat a given one to the punch, I issue a > "select ... for update nowait" and get an operational error. The > "except" block does a "rollback to savepoint"... however, if I > continue on, I still can't use django -- I get an "InternalError". > > I know I can clear this with "connection._rollback()" but there might > be other things in the transaction that are perfectly good.... > > The "rollback to savepoint" should be sufficient: it works when I > simulate with two psql processes. So django (or psycopg2?) must keep > some extra state somewhere. Does anyone know where it is and how I > clear it? > > Thanks! > > -- Shaun -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.