From fadd1a69386ae83ef316f3aee03b2867d8d9fe12 Mon Sep 17 00:00:00 2001 From: Fabio Tranchitella Date: Sun, 25 Mar 2007 03:39:23 +0000 Subject: [PATCH] psycopg2da: better pattern matching for Retry exceptions; it is now compatible with postgresql 8.0, 8.1 and 8.2 exception messages. --- psycopg2da/__init__.py | 1 + psycopg2da/adapter.py | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/psycopg2da/__init__.py b/psycopg2da/__init__.py index e69de29b..fa81adaf 100644 --- a/psycopg2da/__init__.py +++ b/psycopg2da/__init__.py @@ -0,0 +1 @@ +# empty file diff --git a/psycopg2da/adapter.py b/psycopg2da/adapter.py index 352afc2a..dc796008 100644 --- a/psycopg2da/adapter.py +++ b/psycopg2da/adapter.py @@ -379,11 +379,7 @@ def _handle_psycopg_exception(error): # PostgreSQL releases - if so, the different messages should be added # rather than the existing ones changed so this logic works with # different versions. - if msg.startswith( - 'ERROR: could not serialize access due to concurrent update' - ): - raise Retry(sys.exc_info()) - if msg.startswith('ERROR: deadlock detected'): + if 'could not serialize' in msg or 'deadlock detected' in msg: raise Retry(sys.exc_info()) raise