From: Daniele Varrazzo Date: Wed, 18 May 2022 20:45:48 +0000 (+0200) Subject: fix: raise a shorter trackeback on interrupted notify connection X-Git-Tag: 3.1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=799f9d8f03d54b56066c479abe30c8ebd30e9fb3;p=thirdparty%2Fpsycopg.git fix: raise a shorter trackeback on interrupted notify connection --- diff --git a/psycopg/psycopg/connection.py b/psycopg/psycopg/connection.py index 41f5c2920..4c610bf3f 100644 --- a/psycopg/psycopg/connection.py +++ b/psycopg/psycopg/connection.py @@ -916,7 +916,10 @@ class Connection(BaseConnection[Row]): """ while True: with self.lock: - ns = self.wait(notifies(self.pgconn)) + try: + ns = self.wait(notifies(self.pgconn)) + except e.Error as ex: + raise ex.with_traceback(None) enc = pgconn_encoding(self.pgconn) for pgn in ns: n = Notify(pgn.relname.decode(enc), pgn.extra.decode(enc), pgn.be_pid) diff --git a/psycopg/psycopg/connection_async.py b/psycopg/psycopg/connection_async.py index 38a0cb306..ae8715da1 100644 --- a/psycopg/psycopg/connection_async.py +++ b/psycopg/psycopg/connection_async.py @@ -303,7 +303,10 @@ class AsyncConnection(BaseConnection[Row]): async def notifies(self) -> AsyncGenerator[Notify, None]: while True: async with self.lock: - ns = await self.wait(notifies(self.pgconn)) + try: + ns = await self.wait(notifies(self.pgconn)) + except e.Error as ex: + raise ex.with_traceback(None) enc = pgconn_encoding(self.pgconn) for pgn in ns: n = Notify(pgn.relname.decode(enc), pgn.extra.decode(enc), pgn.be_pid)