details: https://code.tryton.org/tryton/commit/3c367a19f5df
branch: default
user: Nicolas Évrard <[email protected]>
date: Wed Mar 25 13:10:39 2026 +0100
description:
Remove direct calls to NOTIFY
In bb52a833e823 we forgot those calls
Closes #14705
diffstat:
trytond/trytond/cache.py | 6 ++----
trytond/trytond/tests/test_cache.py | 16 +++++++++++++++-
2 files changed, 17 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r b28e4764b080 -r 3c367a19f5df trytond/trytond/cache.py
--- a/trytond/trytond/cache.py Thu Mar 26 00:32:49 2026 +0100
+++ b/trytond/trytond/cache.py Wed Mar 25 13:10:39 2026 +0100
@@ -374,8 +374,7 @@
database = backend.Database(dbname)
conn = database.get_connection()
try:
- cursor = conn.cursor()
- cursor.execute('NOTIFY "%s"' % cls._channel)
+ database.notify(conn, cls._channel, "")
conn.commit()
finally:
database.put_connection(conn)
@@ -396,8 +395,7 @@
process_id = cls._local.portable_id
payload = f"{REFRESH_POOL_MSG} {process_id}"
try:
- cursor = conn.cursor()
- cursor.execute(f'NOTIFY "{cls._channel}", %s', (payload,))
+ database.notify(conn, cls._channel, payload)
conn.commit()
finally:
database.put_connection(conn)
diff -r b28e4764b080 -r 3c367a19f5df trytond/trytond/tests/test_cache.py
--- a/trytond/trytond/tests/test_cache.py Thu Mar 26 00:32:49 2026 +0100
+++ b/trytond/trytond/tests/test_cache.py Wed Mar 25 13:10:39 2026 +0100
@@ -8,7 +8,8 @@
from trytond import backend, config
from trytond.cache import (
- LRUDict, LRUDictTransaction, MemoryCache, freeze, unfreeze)
+ REFRESH_POOL_MSG, LRUDict, LRUDictTransaction, MemoryCache, freeze,
+ unfreeze)
from trytond.tests.test_tryton import (
DB_NAME, USER, TestCase, activate_module, with_transaction)
from trytond.transaction import Transaction
@@ -264,6 +265,19 @@
def test_memory_cache_sync(self):
super().test_memory_cache_sync()
+ @with_transaction()
+ def test_memory_cache_refresh_pool(self):
+ "Test MemoryCache refresh_pool uses Database.notify"
+ transaction = Transaction()
+ with patch(
+ 'trytond.backend.Database.notify',
+ side_effect=transaction.database.notify) as notify:
+ cache.refresh_pool(transaction)
+ self.assertEqual(
+ notify.call_args.args[1:],
+ (cache._channel,
+ f"{REFRESH_POOL_MSG} {cache._local.portable_id}"))
+
class LRUDictTestCase(TestCase):
"Test LRUDict"