Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
exit
from Python console within reticulate sessions (#5056)
Addresses #5022, #4982 and #5144 Positron detects that the session is closed whenever the zeroMQ sockets are closed, triggering UI updates, etc. Reticulate Python sessions are managed within the R process, thus when exitting the IPykernel, the process is not necessarily closed - which would make sure the zeroMQ sockets are also closed. This PR makes sure that the IPyKernel closes the zeroMQ sockets before exitting. While this PR fixes the initial issue, it uncovers a another issue that I still couldn't figure out how to fix, but have some understanding of what's happening: If you create a Reticulate Python session, then shut it down (either by typing `exit` or clicking the shutdown button) and then restart the reticulate python session, the LSP for that second session will never correctly start. It seems it gets stuck in the `Starting` state. This is problematic because the next time you click on `Shutdown` to close the Python session it will be stuck again. The reason is that the shutdown routine in: https://github.com/posit-dev/positron/blob/66c701594d7eba0d57bf40c8d04cb488b4464f47/extensions/positron-python/src/client/positron/session.ts#L386-L394 Tries to `deactivate` the LSP, which then blocks in: https://github.com/posit-dev/positron/blob/66c701594d7eba0d57bf40c8d04cb488b4464f47/extensions/positron-python/src/client/positron/lsp.ts#L183-L187 @seeM I suspect that there's still some state that is not completely cleaned up when the IPyKernel exits that's causing the LSP to not start correctly. I spent a good ammount of time trying to figure out what's happening but could not find yet. Do you have suggestions for where to look at? I'm pretty sure that the sockets are created in: https://github.com/posit-dev/positron/blob/a4101740ce6806cbf95ad2aaf45dacd963c2f11d/extensions/positron-python/python_files/positron/positron_ipykernel/lsp.py#L30-L52 And we are somehow waiting for: https://github.com/posit-dev/positron/blob/a4101740ce6806cbf95ad2aaf45dacd963c2f11d/extensions/positron-python/src/client/positron/lsp.ts#L125-L155 Because we never reach the `State.Running`, but we do get `State.Starting`.
- Loading branch information