Skip to content

Commit e9688ba

Browse files
committed
refactor: enhance attribute handling in multiprocessing by ensuring compatibility with all start methods
1 parent 1c5b8c1 commit e9688ba

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

check50/runner.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,8 @@ def __init__(self, check_name, spec, state=None):
343343
def _store_attributes(self):
344344
""""
345345
Store all values from the attributes from run_check.CROSS_PROCESS_ATTRIBUTES on this object,
346-
in case multiprocessing is using spawn as its starting method.
346+
to ensure they are available in child processes regardless of the multiprocessing start method.
347347
"""
348-
349-
# Attributes only need to be passed explicitly to child processes when using spawn
350-
if multiprocessing.get_start_method() != "spawn":
351-
return
352-
353348
self._attribute_values = [eval(name) for name in self.CROSS_PROCESS_ATTRIBUTES]
354349

355350
# Replace all unpickle-able values with nothing, assuming they've been set externally,
@@ -358,7 +353,7 @@ def _store_attributes(self):
358353
for i, value in enumerate(self._attribute_values):
359354
try:
360355
pickle.dumps(value)
361-
except (pickle.PicklingError, AttributeError):
356+
except (pickle.PicklingError, AttributeError, TypeError):
362357
self._attribute_values[i] = None
363358

364359
self._attribute_values = tuple(self._attribute_values)
@@ -373,7 +368,9 @@ def _set_attributes(self):
373368
return
374369

375370
for name, val in zip(self.CROSS_PROCESS_ATTRIBUTES, self._attribute_values):
376-
self._set_attribute(name, val)
371+
# Skip None values - these were unpicklable and should be set by module import
372+
if val is not None:
373+
self._set_attribute(name, val)
377374

378375

379376
@staticmethod

0 commit comments

Comments
 (0)