emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] ob-python hangs on second start [9.5.4 (release_9.5.4-763-g063


From: Ihor Radchenko
Subject: Re: [BUG] ob-python hangs on second start [9.5.4 (release_9.5.4-763-g06373a @ ~/emacs/org-mode/lisp/)]
Date: Fri, 25 Aug 2023 08:52:18 +0000

Peter Mao <peter.mao@gmail.com> writes:

> Expectation:  When running ob-python code blocks, I should be able to
> kill the python session in the *Python* buffer and run another code
> block (or the same one).
>
> Problem:  ob-python works fine on the first execution, but after
> `exit()`ing the python session, it hangs without executing the code.
> After a `C-g`, the prompt in the *Python* session shows up, but one then
> has to re-execute the code block, as none of it has run.

Confirmed.

It looks like `python-shell-first-prompt-hook' does not get triggered
in the described scenario with exit() and we enter infinite loop in the
code below.

    (add-hook
     'python-shell-first-prompt-hook
     #'org-babel-python--setup-session
     nil 'local)))
;; Wait until Python initializes
;; This is more reliable compared to
;; `org-babel-comint-wait-for-output' as python may emit
;; multiple prompts during initialization.
(with-current-buffer py-buffer
  (while (not org-babel-python--initialized)
    (org-babel-comint-wait-for-output py-buffer)))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]