Subject: bug#50514: 28.0.50; org inline call to python src block req C-g to break

From: Augusto Stoffel <[email-masked]>
Date: Wed, 15 Sep 2021 08:28:07 +0200

On Tue, 14 Sep 2021 at 22:20, "Barton, Mark" <[email-masked]> wrote:

>  On Sep 14, 2021, at 12:31 PM, Augusto Stoffel <[email-masked]> wrote:
>
>  Great.  Then we'll fix the spurious line break problem, which is indeed
>  on the Emacs side.  But the other is due to ob-python, which may send
>  code to the interpreter before the first prompt is printed (this can be
>  checked through the variable 'python-shell--first-prompt-received').
>
>  Since I don't use org-babel, I'm afraid I can't help with that part…
>
> So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms, my initialization problem is
> “fixed”. I’m not sure why it would take longer than it did before the changes. Possibly an
> interaction with the antivirus software???

This was probably a problem all along, but went unnoticed until now
because 'python-shell-send-string' used to be simpler.

> I have not tried other values, but may be there is a better
> method for ob-python to determine it is safe than using a sleep-for.

One thing that might work is to block until the shell is ready with something like

    (run-python)
    (with-current-buffer *the-shell-buffer*
      (while (not python-shell--first-prompt-received)
        (accept-process-output (get-buffer-process (current-buffer)))))