From cdd255a73698a6b7b5da3d6d20c2aa6a8b072d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 23 Dec 2022 23:57:17 +0100 Subject: [PATCH] Avoid concurrency failure in cache test with channel We need to ensure that the listener has finished to clear the cache before resume the main thread execution. Closes #11950 --- trytond/trytond/cache.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trytond/trytond/cache.py b/trytond/trytond/cache.py index e087b75155..d1c670ecc8 100644 --- a/trytond/trytond/cache.py +++ b/trytond/trytond/cache.py @@ -369,11 +369,10 @@ class MemoryCache(BaseCache): cursor = conn.cursor() cursor.execute('LISTEN "%s"' % cls._channel) - current_thread.listening = True - # Clear everything in case we missed a payload Pool(dbname).refresh(_get_modules(cursor)) cls._clear_all(dbname) + current_thread.listening = True selector.register(conn, selectors.EVENT_READ) while cls._listener.get((pid, dbname)) == current_thread: