From 18e35f4680d7dd44664d391daebeb56f60516028 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 7 Jul 2014 07:26:44 +0000 Subject: [PATCH] Support poorly-designed WebCyte "maintenance mode". --- __init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/__init__.py b/__init__.py index 47f54fd..6e53915 100644 --- a/__init__.py +++ b/__init__.py @@ -17,6 +17,9 @@ import psycopg2.pool psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) +class ConnectionError(): + pass + class connect(object): def __init__(self, dsn): options = dsn.copy() @@ -38,6 +41,8 @@ class connect(object): self.driver = psycopg2.connect(**options) break except psycopg2.OperationalError, e: + if e.message.startswith('could not connect to server: Connection refused\n'): + raise ConnectionError() if attempt == 2: raise attempt = attempt + 1 -- 2.47.2