subprocess_runner
This file contains some utilities that are useful to run a function inside an independent sub-process.
When the subprocess is finished the memory is fully released, which is useful to avoid memory leaks, especially from tensorflow.
- tensiometer.utilities.subprocess_runner.run_in_process(**kwargs)[source]
Decorator to run a function in a subprocess with optional feedback, monitoring, and timeout capabilities.
- Parameters:
subprocess – whether to execute in a subprocess.
feedback_level – verbosity level from 0 to 3.
context – multiprocessing context (
fork,spawnorforkserver).monitoring – enable monitoring of the subprocess.
monitoring_frequency – interval, in seconds, for monitoring updates.
timeout – maximum runtime in seconds; enables monitoring when set.
- Returns:
wrapped function with subprocess capabilities.
- Raises:
ValueError – if supplied configuration values are invalid.