changeset 4e240b35cbc8 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=4e240b35cbc8
description:
Limit size of cache to reset per notify call
issue8781
review309371003
diffstat:
trytond/cache.py | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (28 lines):
diff -r 1daf4fd5473b -r 4e240b35cbc8 trytond/cache.py
--- a/trytond/cache.py Sun Apr 19 16:36:15 2020 +0200
+++ b/trytond/cache.py Sun Apr 19 16:37:51 2020 +0200
@@ -16,7 +16,7 @@
from trytond import backend
from trytond.config import config
from trytond.transaction import Transaction
-from trytond.tools import resolve
+from trytond.tools import resolve, grouped_slice
__all__ = ['BaseCache', 'Cache', 'LRUDict']
_clear_timeout = config.getint('cache', 'clean_timeout', default=5 * 60)
@@ -213,9 +213,12 @@
dbname = database.name
if not _clear_timeout and transaction.database.has_channel():
with transaction.connection.cursor() as cursor:
- cursor.execute(
- 'NOTIFY "%s", %%s' % cls._channel,
- (json.dumps(list(reset), separators=(',', ':')),))
+ # The count computed as
+ # 8000 (max notify size) / 64 (max name data len)
+ for sub_reset in grouped_slice(reset, 125):
+ cursor.execute(
+ 'NOTIFY "%s", %%s' % cls._channel,
+ (json.dumps(list(sub_reset), separators=(',', ':')),))
else:
connection = database.get_connection(
readonly=False, autocommit=True)