-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ob-async should support :session header-arg #1
Comments
Can async support this? I thought :session was meant to run things in a inferior process which should be asynchronous anyway? |
No, it doesn't. I execute this:
The independent emacs process evaluates it and writes the result on
Before executing it, |
Hmmm, yeah - that's a good point. If we were to serialize the session to a file and then source it in an independent process then the contents of the blocks would need to be idempotent. I wonder if it would be possible to start a persistent session in the child process with async-start and send it the contents of src blocks for evaluation with async-send. |
That may be a good way to do it. That's how python or bash |
I wonder if a thread-based implementation (supported in Emacs 26) would make this easier? See this comment for details. |
This following comment was based on the belief that Emacs 26 would allow multiple threads to execute at once (this is not the case). See discussion following jwiegley/emacs-async#97 (comment). @astahlman I'm not completely familiar with the semantics of sessions (I am assuming they are only for interpreted languages (except Emacs Lisp? See ob-emacs-lisp.el in https://code.orgmode.org/bzg/org-mode/src/master/lisp)) but I believe that you could view sessions as being uniquely accessed using a composite key consisting of the session name and programming language. There are two paths (that I can think of right now) that you could take to implement sessions:
The following discussion, assumes option 1 is the only viable option. Assuming that sessions are lazily initialized (see https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-ruby.el#L109 ; for ob-ruby they are), you would probably need mutexes to guard against concurrent initialization of sessions. You would also probably need to synchronize access to the sessions also. There might be issues if sessions are currently being created in a way that any interactions with them block the main thread. I don't think that this library can integrate sessions without coordinating with upstream. |
@preetpalS Thanks for looking into it, any rate. The discussion in jwiegley/emacs-async#97 was enlightening. |
For R code blocks the :session support is just critical. I can't see much use otherwise. |
Any luck @jkitchin is interested in helping in this? :pray_tone: |
This might already work with ob-ipython (which can support other kernels via Jupyter). In the scimax modifications to ob-ipython (https://github.com/jkitchin/scimax/blob/master/scimax-org-babel-ipython-upstream.el) there is support for async execution that works for ipython, but I guess should work for R too, with an R jupyter kernel. I haven't used other kernels very extensively though, so I don't know if there will be issues with it. |
I've started work on this upstream: |
Updating my previous comment -- I've moved my code for async session evaluation to a standalone repo at https://github.com/jackkamm/ob-session-async |
@jackkamm ob-session-async is great! I've added async session eval for Ruby jackkamm/ob-session-async#2. It works great for me. :) |
Desired behavior
Current behavior
The text was updated successfully, but these errors were encountered: