6
6
from logging .handlers import QueueHandler
7
7
from queue import Empty
8
8
9
- # Important: We must be able to import the client and all parameter classes
10
9
from geophires_x_client import GeophiresXClient
11
10
from geophires_x_client .geophires_input_parameters import EndUseOption
12
11
from geophires_x_client .geophires_input_parameters import ImmutableGeophiresInputParameters
15
14
def run_client_in_process (params_dict : dict , log_queue : multiprocessing .Queue , result_queue : multiprocessing .Queue ):
16
15
"""
17
16
This is the function that each worker process will execute.
18
- It must be a top-level function to be picklable by multiprocessing.
17
+ It must be a top-level function to be pickleable by multiprocessing.
19
18
"""
19
+
20
20
# Configure logging for this worker process to send messages to the shared queue.
21
21
root_logger = logging .getLogger ()
22
22
root_logger .setLevel (logging .INFO )
@@ -32,7 +32,7 @@ def run_client_in_process(params_dict: dict, log_queue: multiprocessing.Queue, r
32
32
result_queue .put (e )
33
33
34
34
35
- class TestMultiprocessingSafety (unittest .TestCase ):
35
+ class MultiprocessingSafetyTestCase (unittest .TestCase ):
36
36
def setUp (self ):
37
37
"""Set up a unique set of parameters for each test."""
38
38
self .params_dict = {
@@ -48,14 +48,15 @@ def setUp(self):
48
48
def test_client_runs_real_geophires_and_caches_across_processes (self ):
49
49
"""
50
50
Tests that GeophiresXClient can run the real geophires.main in multiple
51
- processes and that the cache is shared between them. This test is now
51
+ processes and that the cache is shared between them. This test is
52
52
fully self-contained to prevent resource conflicts with the test runner.
53
53
"""
54
+
54
55
if sys .platform == 'win32' :
55
56
self .skipTest ("The 'fork' multiprocessing context is not available on Windows." )
56
57
57
58
ctx = multiprocessing .get_context ('fork' )
58
- # Use the Manager as a context manager. This is the key to ensuring
59
+ # Use the Manager as a context manager. This is key to ensuring
59
60
# all resources it creates (queues, etc.) are properly shut down
60
61
# at the end of the block, preventing deadlocks.
61
62
with ctx .Manager () as manager :
@@ -79,7 +80,7 @@ def test_client_runs_real_geophires_and_caches_across_processes(self):
79
80
for p in processes :
80
81
p .start ()
81
82
82
- # --- Robust Result Collection ---
83
+ # --- Result Collection ---
83
84
results = []
84
85
for i in range (num_processes ):
85
86
try :
0 commit comments