From 8aaa6240b4b60f52209ec5bce8e8e0bc1ab9dfb2 Mon Sep 17 00:00:00 2001 From: Hsin-Fang Chiang Date: Thu, 28 Sep 2023 16:03:43 -0700 Subject: [PATCH] Use non-thread-local _store in RecordFactoryContextAdapter This needs to be thought about more carefully. --- python/activator/logger.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/activator/logger.py b/python/activator/logger.py index 6e9b7e9d..5b3d2074 100644 --- a/python/activator/logger.py +++ b/python/activator/logger.py @@ -27,7 +27,7 @@ import json import logging import os -import threading +import types import lsst.daf.butler as daf_butler @@ -277,7 +277,9 @@ def __init__(self, factory): self._old_factory = factory # Record factories must be shared to be useful; keep all nontrivial # state in a `local` object to emulate a thread-specific factory. - self._store = threading.local() + # But using threading.local seemed to cause error in some threads. + # TODO: fix this properly + self._store = types.SimpleNamespace() self._store.context = {} def __call__(self, *args, **kwargs):