From 02b981603573f87e193474ca5fcc2e7327ec8565 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 12 Jul 2026 22:14:36 +0300 Subject: [PATCH 1/3] fix: test_set_env__thread_safety always works slowly on remote_ops Logging is improved, too. --- tests/test_os_ops_common.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/test_os_ops_common.py b/tests/test_os_ops_common.py index c4c9cdde..170ea191 100644 --- a/tests/test_os_ops_common.py +++ b/tests/test_os_ops_common.py @@ -3727,18 +3727,38 @@ def test_set_env__thread_safety( C_NUM_THREADS = 2 - if OsOpsHelpers.is_localhost(os_ops): - C_NUM_ITERATIONS = 2000 - else: + if type(os_ops).__name__ == "RemoteOperations": C_NUM_ITERATIONS = 200 + else: + C_NUM_ITERATIONS = 2000 + + logging.info("NUM_ITERATIONS: {}".format(C_NUM_ITERATIONS)) # Queue for collecting exceptions from background threads exceptions_queue = queue.Queue() # The function that each thread will run - def thread_worker(var_name: str, var_value: str, iterations: int): + def thread_worker( + thread_num: int, + var_name: str, + var_value: str, + iterations: int, + ): + logging.info("Hello from thread [{}].".format( + thread_num, + )) + try: - for _ in range(iterations): + nPass = 0 + while nPass < iterations: + nPass += 1 + + if (nPass % 100) == 0: + logging.info("thread [{}]: {}".format( + thread_num, + nPass, + )) + # 1. The thread writes ITS own isolated variable os_ops.set_env(var_name, var_value) @@ -3755,7 +3775,12 @@ def thread_worker(var_name: str, var_value: str, iterations: int): # 3. Clean up after yourself os_ops.reset_env(var_name, None) assert os_ops.environ(var_name) is None + continue + logging.info("thread [{}] finished ({})".format( + thread_num, + nPass, + )) except Exception as e: # If something goes wrong, we pass the error to the main test thread exceptions_queue.put(e) @@ -3774,7 +3799,7 @@ def thread_worker(var_name: str, var_value: str, iterations: int): threads[i] = threading.Thread( target=thread_worker, - args=(thread_name, thread_val, C_NUM_ITERATIONS), + args=(i, thread_name, thread_val, C_NUM_ITERATIONS), ) continue From 31bc740a2addfc7bcf9e195de9be80037e371c5f Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 12 Jul 2026 22:26:34 +0300 Subject: [PATCH 2/3] logging in test_set_env__thread_safety is corrected --- tests/test_os_ops_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_os_ops_common.py b/tests/test_os_ops_common.py index 170ea191..7afc6877 100644 --- a/tests/test_os_ops_common.py +++ b/tests/test_os_ops_common.py @@ -3751,14 +3751,14 @@ def thread_worker( try: nPass = 0 while nPass < iterations: - nPass += 1 - if (nPass % 100) == 0: logging.info("thread [{}]: {}".format( thread_num, nPass, )) + nPass += 1 + # 1. The thread writes ITS own isolated variable os_ops.set_env(var_name, var_value) From 5cd4113e85522f1952da465b52b1e5e8a51181f3 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 12 Jul 2026 22:38:32 +0300 Subject: [PATCH 3/3] logging in test_set_env__thread_safety is corrected (one more time) --- tests/test_os_ops_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_os_ops_common.py b/tests/test_os_ops_common.py index 7afc6877..8daa0b81 100644 --- a/tests/test_os_ops_common.py +++ b/tests/test_os_ops_common.py @@ -3751,7 +3751,7 @@ def thread_worker( try: nPass = 0 while nPass < iterations: - if (nPass % 100) == 0: + if nPass > 0 and (nPass % 100) == 0: logging.info("thread [{}]: {}".format( thread_num, nPass,