Use autocommit connection to LISTEN

This is needed to receive notification in a timely manner.

issue9966
review333541002
This commit is contained in:
Cédric Krier committed 2021-01-03 13:00:26 +01:00
1 parent d766a67fbb
commit 18fc13fb15
2 files changed
+2 -4

No files matched your search

+1 -2
View File
@@ -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)
+1 -2
View File
@@ -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], [], [])