From: Mark Huang Date: Sun, 11 Feb 2007 04:53:40 +0000 (+0000) Subject: - try obtaining another cursor once if it appears to be closed X-Git-Tag: PLCAPI-4.2-0~191 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c4b7fddda7252f72f052010ab8878f2025d9e07f;p=plcapi.git - try obtaining another cursor once if it appears to be closed --- diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index 495435ec..57321f54 100644 --- a/PLC/PostgreSQL.py +++ b/PLC/PostgreSQL.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: PostgreSQL.py,v 1.11 2006/12/04 19:10:47 mlhuang Exp $ +# $Id: PostgreSQL.py,v 1.12 2007/02/08 15:15:21 mlhuang Exp $ # import psycopg2 @@ -153,7 +153,13 @@ class PostgreSQL: if psycopg2: query = re.sub(r'(%\([^)]*\)|%)[df]', r'\1s', query) - cursor.executemany(query, param_seq) + try: + cursor.executemany(query, param_seq) + except InterfaceError: + # Try one more time with another cursor + cursor = self.cursor = self.db.cursor() + cursor.executemany(query, param_seq) + (self.rowcount, self.description, self.lastrowid) = \ (cursor.rowcount, cursor.description, cursor.lastrowid) except Exception, e: