changeset 579f51ed2a78 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=579f51ed2a78
description:
        Use autocommit connection to LISTEN

        This is needed to receive notification in a timely manner.

        issue9966
        review333541002
diffstat:

 trytond/bus.py   |  3 +--
 trytond/cache.py |  3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r c6f80e10b331 -r 579f51ed2a78 trytond/bus.py
--- a/trytond/bus.py    Sun Dec 27 00:19:30 2020 +0100
+++ b/trytond/bus.py    Sun Jan 03 13:00:26 2021 +0100
@@ -149,12 +149,11 @@
             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 -r c6f80e10b331 -r 579f51ed2a78 trytond/cache.py
--- a/trytond/cache.py  Sun Dec 27 00:19:30 2020 +0100
+++ b/trytond/cache.py  Sun Jan 03 13:00:26 2021 +0100
@@ -293,13 +293,12 @@
             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], [], [])

Reply via email to