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.ipynb executes cells directly in its own process, where start_ipython is 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.ipynb launches an IPython kernel as a separate subprocess (via IPKernelApp, not start_ipython), so multiprocessing works normally — Loky can spawn workers and cloudpickle handles function serialisation across processes.

  • This function checks for start_ipython in the call stack to distinguish the two cases.

  • When IPython CLI is detected, callers should fall back to max_workers=1 and log a warning suggesting jupyter execute.

Return type:

bool