From 18fc13fb1544939360a9e33d823f3eaaa82b21ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 3 Jan 2021 13:00:26 +0100 Subject: [PATCH] Use autocommit connection to LISTEN This is needed to receive notification in a timely manner. issue9966 review333541002 --- trytond/bus.py | 3 +-- trytond/cache.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/trytond/bus.py b/trytond/bus.py index b2869dcdc8..2c07a22d97 100644 --- a/trytond/bus.py +++ b/trytond/bus.py @@ -149,12 +149,11 @@ class LongPollingBus: raise NotImplementedException logger.info("listening on channel '%s'", cls._channel) - conn = db.get_connection() + conn = db.get_connection(autocommit=True) pid = os.getpid() try: cursor = conn.cursor() cursor.execute('LISTEN "%s"' % cls._channel) - conn.commit() cls._messages[database] = messages = _MessageQueue(_cache_timeout) diff --git a/trytond/cache.py b/trytond/cache.py index 2f39d06134..489454fd88 100644 --- a/trytond/cache.py +++ b/trytond/cache.py @@ -293,13 +293,12 @@ class MemoryCache(BaseCache): raise NotImplementedError logger.info("listening on channel '%s' of '%s'", cls._channel, dbname) - conn = database.get_connection() + conn = database.get_connection(autocommit=True) pid = os.getpid() current_thread = threading.current_thread() try: cursor = conn.cursor() cursor.execute('LISTEN "%s"' % cls._channel) - conn.commit() while cls._listener.get((pid, dbname)) == current_thread: readable, _, _ = select.select([conn], [], [])