From b78276b643431cc586c66d2599e8c2ea7721da63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 27 Jul 2026 12:10:00 +0200 Subject: [PATCH] Protect writing configuration of tryton with a thread lock Closes #6114 (grafted from d09f4b4b8b5a163ae02d9f066922e0999022b4f8) --HG-- branch : 8.0 --- tryton/tryton/config.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tryton/tryton/config.py b/tryton/tryton/config.py index 0bcac92d46..6c9d00da3d 100644 --- a/tryton/tryton/config.py +++ b/tryton/tryton/config.py @@ -9,6 +9,7 @@ import os import shutil import sys from tempfile import NamedTemporaryFile +from threading import Lock from gi.repository import GdkPixbuf @@ -16,6 +17,7 @@ from tryton import __version__ logger = logging.getLogger(__name__) _ = gettext.gettext +_lock = Lock() def _reverse_series_iterator(starting_version): @@ -172,8 +174,9 @@ class ConfigManager(object): if not parser.has_section(section): parser.add_section(section) parser.set(section, name, str(self.config[entry])) - with open(self.rcfile, 'w') as fp: - parser.write(fp) + with _lock: + with open(self.rcfile, 'w') as fp: + parser.write(fp) except IOError: logger.warn("Unable to write config file %s", self.rcfile) return False