emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [BUG] Unexpected result when evaluating python src block asynchronou


From: Bruno Barbier
Subject: Re: [BUG] Unexpected result when evaluating python src block asynchronously [9.7-pre (release_9.6.17-1131-gc9ed03.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
Date: Tue, 06 Feb 2024 20:24:13 +0100

Hi Ihor, Jack,

Ihor Radchenko <yantar92@posteo.net> writes:

> Jack Kamm <jackkamm@gmail.com> writes:
>

>> I agree that it would be good to redesign it, but am not sure where to
>> start.
>
> For example,
>
> 1. Change `org-babel-comint-async-register' to return UUID and to store
>    PARAMS as passed by the backend (current approach with PARAMS being
>    derived from src blocks prevents backends to transform src block
>    PARAMS dynamically).
> 2. Change `org-babel-insert-result' to handle :async t specially,
>    inserting something reliable, like #+async: <UUID> in place of result
>    without performing extra transformations.
> 3. Change `org-babel-insert-result' to accept an internal parameter
>    that will make it replace #+async: <UUID> keyword rather than perform
>    normal result insertion.
> 4. Change `org-babel-comint-async-filter' to use the previously passed
>    PARAMS, remove :async t from them, and arrange the call to
>    `org-babel-insert-result' to replace the #+async: <UUID> keyword.
>

FWIW, I've been trying to use asynchronous blocks for everything, not
only the source blocks that are based on the comint mode.  I think it
would be good if ob-core itself could provide an asynchronous API.  I've
modified my Org so that it does have such an API.  This is work in
progress; let me describe it.

I've modified ob-core itself to allow asynchronicity.  In the
asynchrosous case, instead of calling:

  (org-babel-execute:LANG body params)

I'm calling:

  (org-babel-schedule:LANG body params handle-result)

where `org-babel-schedule:LANG' is in charge of calling `handle-result'
with the result (or the error) when it is known; `handle-result' takes
care to call `org-babel-insert-result' at the correct place (and
`org-babel-insert-result' is only called with a real result).

While the execution is pending, I'm using the same technique that Org is
using when a source block is being edited: the result is left untouched,
but below an overlay.  The overlay is used to know where to insert the
result and to display the status/progress of the execution.  If the file
is closed and the execution fails, nothing is lost, the old result is
still available.

If that technique looks safe enough and interesting, I can prepare a set
of patches so that we can discuss it further and, maybe, add it in Org.

Let me know,
Thanks,

Bruno










reply via email to

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