is_running_in_ipython#
API documentation for tradeexecutor.utils.cpu.is_running_in_ipython Python function.
- is_running_in_ipython()[source]#
Detect if we are running inside the IPython CLI (not a Jupyter kernel).
ipython notebook.ipynbexecutes cells directly in its own process, wherestart_ipythonis on the call stack. Spawning child processes via Loky/joblib fails because IPython’s dynamic__main__module cannot be properly resolved in spawned worker processes.jupyter execute notebook.ipynblaunches an IPython kernel as a separate subprocess (viaIPKernelApp, notstart_ipython), so multiprocessing works normally — Loky can spawn workers and cloudpickle handles function serialisation across processes.This function checks for
start_ipythonin the call stack to distinguish the two cases.When IPython CLI is detected, callers should fall back to
max_workers=1and log a warning suggestingjupyter execute.
- Return type: