Reputation: 2836
We are using jupyterLab for some long running operations (doing physic simulations in our case). The user should be able to stop these operations safely without killing the kernel.
Is there a clean ways to do this?
Are there maybe even best practices for this?
My cell looks something like this:
environment = gym.make()
running = True
while running:
environment.step()
running = ???
serialize(environment)
Upvotes: 1
Views: 3407
Reputation: 867
According to https://stackoverflow.com/a/19040553/, IPython interrupts the kernel by sending a SIGINT. Shouldn't it be possible to catch and handle the signal programmatically, as described in How to stop an infinite loop safely in Python?.
Edit: This sounds helpful: graceful interrupt of while loop in ipython notebook
Upvotes: 1