From 13441028e1d087c9ecf96d9fe4349a0e82350afc 2019-11-22 17:46:28 From: Matthias Bussonnier Date: 2019-11-22 17:46:28 Subject: [PATCH] Fix the issue with %run-ing something with multiprocessing This should fix gh-9978 and gh-11941 --- diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index d9e66b5..438d0b5 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -853,6 +853,8 @@ python-profiler package from non-free.""") sys.argv = save_argv if restore_main: sys.modules['__main__'] = restore_main + if '__mp_main__' in sys.modules: + sys.modules['__mp_main__'] = restore_main else: # Remove from sys.modules the reference to main_mod we'd # added. Otherwise it will trap references to objects