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)