From 5e83907ca72d3fd7fa019a72ff0818646b360dd0 Mon Sep 17 00:00:00 2001 From: Zaar Hai Date: Wed, 26 Aug 2015 21:37:14 +0300 Subject: [PATCH] Fixed ping to handle failures properly. Fixes #115 in the right way. --- momoko/connection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/momoko/connection.py b/momoko/connection.py index 1496454..b0ba7c8 100644 --- a/momoko/connection.py +++ b/momoko/connection.py @@ -556,7 +556,10 @@ def on_ping_done(ping_fut): try: ping_fut.result() except psycopg2.Error as error: - ping_future.set_exc_info(error) + if conn.closed: + ping_future.set_exception(self._no_conn_availble_error) + else: + ping_future.set_exc_info(sys.exc_info()) self.putconn(conn) else: ping_future.set_result(conn)