From ae615fb7d9eb29c3289c708a2f13e5c1bb927834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 25 May 2018 09:25:46 +0200 Subject: [PATCH] threads: make sure logger and substitution singletons are not reused (#24078) --- wcs/qommon/__init__.py | 2 +- wcs/qommon/publisher.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wcs/qommon/__init__.py b/wcs/qommon/__init__.py index 5b16b262..d7d31749 100644 --- a/wcs/qommon/__init__.py +++ b/wcs/qommon/__init__.py @@ -48,7 +48,7 @@ class TenantAwareThread(threading.Thread): def __init__(self, *args, **kwargs): self.publisher = copy.copy(get_publisher()) if self.publisher: - self.publisher.pgconn = None + self.publisher.reset() super(TenantAwareThread, self).__init__(*args, **kwargs) def run(self): diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py index 782b04da..9cd85c68 100644 --- a/wcs/qommon/publisher.py +++ b/wcs/qommon/publisher.py @@ -767,6 +767,12 @@ class QommonPublisher(Publisher, object): publisher.set_config() return publisher + def reset(self): + # reset structures that would otherwise be shared between threads + self.pgconn = None + self._app_logger = None + self.substitutions = Substitutions() + extra_dirs = None @classmethod def register_extra_dir(cls, dir): -- 2.17.0