jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

Locked src_block cells after running dead python sessions

Open fraricci opened this issue 1 year ago • 5 comments

Hi there.

I had the following happening and wanted to know if it's a bug or it's more a misuse of the package on my end.

I have an org document with some src blocks with a remote python session. When that session ends I run that cell by accident, the cell is "locked" and any edits is forbidden. I think this is done using an overlay. Now, since that session does not exist anymore, the connection hangs for a while and I just stop it (C-g). But, the overlay stays and that part of the buffer is not editable anymore.

Now, should I just wait that jupyter-emacs realizes that the session has gone, gets back to me with some message, and unlocks that src block? Or this logic is not implemented yet. Or just be careful not to run cells connected to dead sessions ;-)

What I ended up doing is to remove the overlay manually with an dedicated emacs function with the start and end of that region, but it's pretty annoying.

Any feedback is appreciate.

Thanks

fraricci avatar May 23 '24 15:05 fraricci

I have observed this too but can't reliably recreate on local jupyter sessions.

5183nischal avatar May 24 '24 07:05 5183nischal

Making a source block non-editable during execution is a new feature that I added so that it would be more obvious that that execution is taking place. There may be some kinks to work out. It does look like some logic needs to be implemented to handle this case and is not a user error.

nnicandro avatar Jun 04 '24 10:06 nnicandro

Thanks for your clear reply! I actually found this new feature useful and good looking. So, yeah, it just needs some logic to make it editable again in case of issues.

On a similar line, actually, I always wanted to have something in the modeline that makes clear the kernel status, but not sure how to do it.

fraricci avatar Jun 04 '24 13:06 fraricci

On a similar line, actually, I always wanted to have something in the modeline that makes clear the kernel status, but not sure how to do it.

You can start with something like

(jupyter-org-with-src-block-client
 (equal (jupyter-execution-state jupyter-current-client) "busy"))

But this would only work with point inside a source block. I don't know what would make sense if you wanted this to work outside of a source block since there can be many sessions associated with a single Org file.

nnicandro avatar Jun 04 '24 14:06 nnicandro

Workaround to remove the lock:

(defun my/org-jupyter-remove-overlay ()
  (interactive)
  (jupyter-org--remove-overlay (jupyter-org-request-at-point))
  (jupyter-org-abort (jupyter-org-request-at-point)))

veprbl avatar Aug 01 '24 19:08 veprbl