From: Tom <tmbdev@gmail.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Karl Voit <news1142@karl-voit.at>, emacs-orgmode@gnu.org
Subject: Re: asynchronous python code blocks in org-mode
Date: Tue, 1 Dec 2015 12:19:31 -0800 [thread overview]
Message-ID: <CABdbsnBGyRuC3c_GUTfPsbgKe9FJTqYrd8OKJgXRpDxgTppr8A@mail.gmail.com> (raw)
In-Reply-To: <m2poyrqjro.fsf@andrew.cmu.edu>
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
On Mon, Nov 30, 2015 at 1:06 PM, John Kitchin <jkitchin@andrew.cmu.edu>
wrote:
> I have not thought about sessions and asynchronous execution. It would
> mean a queue and a different way to pass code to the process, which I
> have not thought through yet. What to do when there are dependencies for
> example,...
>
A good way of converting synchronous into asynchronous code is to use
futures/promises. Usually, that's done via data structures, but within
Emacs buffers, it could be done via text strings.
How might that work? org-babel-execute:python could wait for, say, 0.1 sec
for an immediate result. If the computation doesn't finish within that
time, it returns a "future", a magic string like
"org_mode_future_result(1234) ###MAGIC###". This would then get inserted as
output into the org-mode buffer. Later, when the actual result becomes
available from the subprocess, that invokes a callback on the org-python
mode buffer and replaces tihs magic string with the actual result, and
dequeues and executes the next command if necessary.
(Picking a Python-parseable expression would even allow futures to be used
in some other Python computations as if it were an actual value.)
I think that would allow much of the current API to remain in place.
Obviously, some things simply can't work. For example,
org-babel-reassemble-table expects an actual result, not a future; such
post-processing would have to move to a hook function, which probably would
be cleaner anyway.
Tom
[-- Attachment #2: Type: text/html, Size: 2074 bytes --]
next prev parent reply other threads:[~2015-12-01 20:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 16:52 asynchronous python code blocks in org-mode John Kitchin
2015-11-30 11:38 ` Karl Voit
2015-11-30 21:06 ` John Kitchin
2015-12-01 20:19 ` Tom [this message]
2015-12-01 23:07 ` John Kitchin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABdbsnBGyRuC3c_GUTfPsbgKe9FJTqYrd8OKJgXRpDxgTppr8A@mail.gmail.com \
--to=tmbdev@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jkitchin@andrew.cmu.edu \
--cc=news1142@karl-voit.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).