From 6bdedeae66414f4da245d099557187e7004a733b Mon Sep 17 00:00:00 2001 From: Andy Salnikov Date: Wed, 12 Apr 2023 13:16:42 -0700 Subject: [PATCH 1/2] Add workaround for Python threading bug (DM-38669) The bug causes occasional issues with multi-process pipeline executions with pytest using concurrent running. This is a known issue (https://github.com/python/cpython/issues/102512) which will eventually be fixed in Python, at that time the patch should become no-op and can be removed. --- python/lsst/ctrl/mpexec/mpGraphExecutor.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/lsst/ctrl/mpexec/mpGraphExecutor.py b/python/lsst/ctrl/mpexec/mpGraphExecutor.py index b9097b41..d5605bc2 100644 --- a/python/lsst/ctrl/mpexec/mpGraphExecutor.py +++ b/python/lsst/ctrl/mpexec/mpGraphExecutor.py @@ -30,6 +30,7 @@ import pickle import signal import sys +import threading import time from collections.abc import Iterable from enum import Enum @@ -141,6 +142,15 @@ def _executeJob( snd_conn : `multiprocessing.Connection` Connection to send job report to parent process. """ + # This terrible hack is a workaround for Python threading bug: + # https://github.com/python/cpython/issues/102512. Should be removed + # when fix for that bug is deployed. Inspired by + # https://github.com/QubesOS/qubes-core-admin-client/pull/236/files. + thread = threading.current_thread() + if isinstance(thread, threading._DummyThread): + if getattr(thread, "_tstate_lock", "") is None: + thread._set_tstate_lock() # type: ignore[attr-defined] + if logConfigState and not CliLog.configState: # means that we are in a new spawned Python process and we have to # re-initialize logging From 5af61ce56ba24f98346feffd2bd5834801336954 Mon Sep 17 00:00:00 2001 From: Andy Salnikov Date: Wed, 12 Apr 2023 14:39:09 -0700 Subject: [PATCH 2/2] Unpin sqlalchemy version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e4e249e1..b081e3d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,4 @@ git+https://github.com/lsst/daf_butler@main#egg=lsst-daf-butler git+https://github.com/lsst/utils@main#egg=lsst-utils git+https://github.com/lsst/pipe_base@main#egg=lsst-pipe-base git+https://github.com/lsst/pex_config@main#egg=lsst-pex-config -sqlalchemy <2.0 +sqlalchemy