From e37ea59190949665cf9e9d5ddcbe7e4edbf1c768 Mon Sep 17 00:00:00 2001 From: kp-cat <52385411+kp-cat@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:41:01 +0100 Subject: [PATCH 1/2] fix concurrency_process test: ConfigCat client cannot be pass to other process: reason="TypeError: can't pickle _thread.lock objects". To avoid this, we pass only the sdk_key and get the singleton instance in the process. --- configcatclienttests/test_concurrency.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/configcatclienttests/test_concurrency.py b/configcatclienttests/test_concurrency.py index cdfc3d9..f32bed0 100644 --- a/configcatclienttests/test_concurrency.py +++ b/configcatclienttests/test_concurrency.py @@ -12,24 +12,29 @@ logging.basicConfig(level=logging.WARN) -def _manual_force_refresh(client, repeat=10, delay=0.1): - for i in range(repeat): +def _manual_force_refresh(sdk_key, repeat=10, delay=0.1): + client = configcatclient.get(sdk_key) + for _ in range(repeat): client.force_refresh() sleep(delay) class ConcurrencyTests(unittest.TestCase): - @pytest.mark.skipif(sys.platform == 'win32' or sys.platform == 'darwin', reason="TypeError: can't pickle _thread.lock objects") + def test_concurrency_process(self): - client = configcatclient.get('PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A') + sdk_key = "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A" + client = configcatclient.get(sdk_key) value = client.get_value('keySampleText', False, User('key')) print("'keySampleText' value from ConfigCat: " + str(value)) - p1 = multiprocessing.Process(target=_manual_force_refresh, args=(client,)) - p2 = multiprocessing.Process(target=_manual_force_refresh, args=(client,)) + p1 = multiprocessing.Process(target=_manual_force_refresh, args=(sdk_key,)) + p2 = multiprocessing.Process(target=_manual_force_refresh, args=(sdk_key,)) p1.start() p2.start() p1.join() p2.join() client.close() + + self.assertEqual(p1.exitcode, 0, f"Process {p1.pid} exited with code {p1.exitcode}") + self.assertEqual(p2.exitcode, 0, f"Process {p2.pid} exited with code {p2.exitcode}") From 408fd8db8e54df29907701f2a1b995f09563d765 Mon Sep 17 00:00:00 2001 From: kp-cat <52385411+kp-cat@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:46:51 +0100 Subject: [PATCH 2/2] fix CI --- configcatclienttests/test_concurrency.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configcatclienttests/test_concurrency.py b/configcatclienttests/test_concurrency.py index f32bed0..7a2050d 100644 --- a/configcatclienttests/test_concurrency.py +++ b/configcatclienttests/test_concurrency.py @@ -36,5 +36,5 @@ def test_concurrency_process(self): client.close() - self.assertEqual(p1.exitcode, 0, f"Process {p1.pid} exited with code {p1.exitcode}") - self.assertEqual(p2.exitcode, 0, f"Process {p2.pid} exited with code {p2.exitcode}") + self.assertEqual(p1.exitcode, 0, "Process {0} exited with code {1}".format(p1.pid, p1.exitcode)) + self.assertEqual(p2.exitcode, 0, "Process {0} exited with code {1}".format(p2.pid, p2.exitcode))