Skip to content

Commit 09bc14a

Browse files
committed
Fix: Move run_with_env() before freeze_support() for PyInstaller compatibility
The run_with_env() function must be defined before multiprocessing.freeze_support() to ensure proper pickling in frozen executables. When defined after freeze_support(), PyInstaller cannot properly register the function for multiprocessing, causing "Can't get attribute 'run_with_env'" errors in worker processes. This fixes the issue where isolated process computations hang in frozen builds while working correctly in standard Python distributions. Fixes isolated process execution in PyInstaller-built DataLab v1.0.2+
1 parent d32e5fa commit 09bc14a

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

datalab/gui/processor/base.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ def insert_processing_parameters(
195195
obj.set_metadata_option(PROCESSING_PARAMETERS_OPTION, pp.to_dict())
196196

197197

198+
def run_with_env(func: Callable, args: tuple, env_json: str) -> CompOut:
199+
"""Wrapper to apply environment config before calling func
200+
201+
Args:
202+
func: function to call
203+
args: function arguments
204+
env_json: JSON string with environment configuration
205+
206+
Returns:
207+
Computation output object containing the result, error message,
208+
or warning message.
209+
"""
210+
sigima_options.set_env(env_json)
211+
sigima_options.ensure_loaded_from_env() # recharge depuis l'env
212+
return wng_err_func(func, args)
213+
214+
198215
# Enable multiprocessing support for Windows, with frozen executable (e.g. PyInstaller)
199216
multiprocessing.freeze_support()
200217

@@ -221,22 +238,6 @@ def insert_processing_parameters(
221238
POOL: Pool | None = None
222239

223240

224-
def run_with_env(func: Callable, args: tuple, env_json: str) -> CompOut:
225-
"""Wrapper to apply environment config before calling func
226-
227-
Args:
228-
func: function to call
229-
args: function arguments
230-
231-
Returns:
232-
Computation output object containing the result, error message,
233-
or warning message.
234-
"""
235-
sigima_options.set_env(env_json)
236-
sigima_options.ensure_loaded_from_env() # recharge depuis l'env
237-
return wng_err_func(func, args)
238-
239-
240241
class WorkerState(Enum):
241242
"""Worker states for computation lifecycle."""
242243

0 commit comments

Comments
 (0)