emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
929 stars 90 forks source link

Async kernel restart in org mode? #159

Open Yevgnen opened 5 years ago

Yevgnen commented 5 years ago

When I run commands like jupyter-org-restart-kernel-*, the server often take some time (seconds) to finish restarting and Emacs hangs, it is possible to make this action asynchronous?

nnicandro commented 5 years ago

It may be possible. I don't know what would happen if you made it asynchronous and tried to send requests before the restart is complete. The restarting functions like jupyter-repl-restart-kernel would have to have a callback function that it evaluates once the kernel is restarted. You would also have to have the jupyter-org-restart-kernel-* functions and any other functions that call restarting functions take into account the asynchronous behavior.

the server

Are you referring to a notebook kernel server? Or just a kernel process? If you are talking about a notebook server, I don't think jupyter-repl-restart-kernel currently handles restarting a notebook kernel properly (which I will fix).

Even if it did, in addition to passing jupyter-repl-restart-kernel a callback function you would probably have to modify jupyter-api-restart-kernel to take a callback function.

If you are willing to implement this, I'd be happy to assist by answering any questions that may come up.

Yevgnen commented 5 years ago

the server

Sorry, maybe I should say the kernel process.

Starting python3 kernel process...done
Requesting kernel info...done
Restarting kernel...
Starting python3 kernel process...done
nnicandro commented 5 years ago

I don't think jupyter-repl-restart-kernel currently handles restarting a notebook kernel properly (which I will fix).

Should be fixed by 39974d184188966fd0c948a25320209c9de74af6.