From 19d6fb08fc8744feee0f5deaa9400dd52a5c65c8 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 12 Jul 2026 22:33:06 +0300 Subject: [PATCH 1/2] 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 bcfb6a1..b3cfdc3 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: + 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) @@ -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 46d54ae66fc2072017351fcaa7d719efa62271eb Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 12 Jul 2026 22:50:19 +0300 Subject: [PATCH 2/2] test_set_env__thread_safety: logging is corrected --- 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 b3cfdc3..9f1cfc5 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,