Is there a way of programmatically reset an IPython kernel without restarting it?
Currently I am calling KernelManager.restart_kernel
but that is quite slow.
The purpose of this is to isolate unit tests in a py.test
plugin for using Notebook cells as unit tests. If you have other ideas to achieve this I'd love suggestions. The code is here:
https://github.com/zonca/pytest-ipynb/blob/master/pytest_ipynb/plugin.py#L100
I used the %reset
IPython magic function instead of restarting the kernel. That removes all the variables but does not perform again the imports. That is suitable for my application.
See IPython docs: http://ipython.readthedocs.org/en/stable/interactive/magics.html?highlight=magic#magic-reset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With