Remove direct calls to NOTIFY

In bb52a833e823 we forgot those calls

Closes #14705
This commit is contained in:
Nicolas Évrard
2026-03-25 13:10:39 +01:00
parent 39a22ae74f
commit d47ddb9903
2 changed files with 17 additions and 5 deletions
+2 -4
View File
@@ -374,8 +374,7 @@ class MemoryCache(BaseCache):
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 @@ class MemoryCache(BaseCache):
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)
+15 -1
View File
@@ -8,7 +8,8 @@ from unittest.mock import patch
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 @@ class MemoryCacheChannelTestCase(MemoryCacheTestCase):
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"