changeset 5c1e3ca27940 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=5c1e3ca27940
description:
        Use autocommit connection to LISTEN

        This is needed to receive notification in a timely manner.

        issue9966
        review333541002
        (grafted from 579f51ed2a7801acc1cfe5eb676db5a0da461dbb)
diffstat:

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

diffs (35 lines):

diff -r a7a06a22b95b -r 5c1e3ca27940 trytond/bus.py
--- a/trytond/bus.py    Fri Jan 01 16:10:18 2021 +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 a7a06a22b95b -r 5c1e3ca27940 trytond/cache.py
--- a/trytond/cache.py  Fri Jan 01 16:10:18 2021 +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