threads: make sure logger and substitution singletons are not reused (#24078)

This commit is contained in:
Frédéric Péters 2018-05-25 09:25:46 +02:00
parent 3cd48901e7
commit 93374961c2
2 changed files with 7 additions and 1 deletions

View File

@ -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.detach()
super(TenantAwareThread, self).__init__(*args, **kwargs)
def run(self):

View File

@ -767,6 +767,12 @@ class QommonPublisher(Publisher, object):
publisher.set_config()
return publisher
def detach(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):