Skip to content

Instantly share code, notes, and snippets.

@FelipeLema
Created December 17, 2021 19:39
Show Gist options
  • Save FelipeLema/6c47650a304c402cd0ecde880fb60c26 to your computer and use it in GitHub Desktop.
Save FelipeLema/6c47650a304c402cd0ecde880fb60c26 to your computer and use it in GitHub Desktop.
describe problem with: `ob-async`: not reporting errors as with non-async default Org Babel

Issue Reporting Checklist

This checklist will help you diagnose problems with your ob-async setup.

Instructions

Execute the src blocks one at a time with ctrl-c ctrl-c to ensure that ob-async-org-babel-execute-src-block is used for files with the :async header-arg. If by the end of this file your issue isn’t solved, open an issue on Github with the contents of this file.

First, make sure you can execute emacs-lisp src blocks without the async header argument. Otherwise you’ve got bigger problems, and none of this is going to work.

(message "Yes, I can synchronously execute emacs-lisp from an org-babel src block.")

Checklist

First, let’s make sure you can run a basic async process without org-babel and/or ob-async (this is adapted from the example in the emacs-async README)

(makunbound 'ob-async/troubleshooting-sentinel) ;; make it re-entrant

(async-start
 ;; What to do in the child process
 (lambda ()
  (message "This is a test")
  222)
 ;; What to do (in the parent) when the child finishes
 (lambda (result)
   (setq ob-async/troubleshooting-sentinel result)
   (format "Async process done, result should be 222: %s" result)))

(let ((elapsed-secs 0)
      (deadline-secs 5))
  (while (and
          (not (boundp 'ob-async/troubleshooting-sentinel))
          (< elapsed-secs deadline-secs))
    (cl-incf elapsed-secs)
    (sleep-for 1)))

(if (boundp 'ob-async/troubleshooting-sentinel)
    (message "Yes, we are able to run async functions (result was %s)"
             ob-async/troubleshooting-sentinel)
  (message "Failed to run a basic async function!"))

From where are you loading ob-async?

(symbol-file 'ob-async-org-babel-execute-src-block)
(message "PID: %s\nEmacs version: %s\norg version: %s\nPath to org: %s" (emacs-pid) (emacs-version) (org-version) (symbol-file 'org-version))

Execution of the :async block occurs in an Emacs subprocess. Are you using a consistent version of emacs and org-mode across both processes? Compare the output of this block the output of the previous block.

(message "PID: %s\nEmacs version: %s\norg version: %s\nPath to org: %s" (emacs-pid) (emacs-version) (org-version) (symbol-file 'org-version))

The Emacs subprocess inherits the value of org-babel-load-languages from its parent. Here are the languages which are loaded in the subprocess. If you don’t see your desired language here, it means you never added it to org-babel-load-languages (in the parent process).

org-babel-load-languages

If you’re still facing problems, turn on async debugging.

;; see https://github.com/astahlman/ob-async/pull/78 
"not valid because I'm using https://github.com/FelipeLema/ob-async/tree/session-support-1"

If possible, replace the following block with a block that reproduces your problem, then execute it.

(message "I'm executed in a subprocess.")

This is the elisp that was sent to the Emacs subprocess. If there’s still nothing obviously wrong, file an issue on GitHub and include the contents of this file as a Gist.

;; see https://github.com/astahlman/ob-async/pull/78 
"not valid because I'm using https://github.com/FelipeLema/ob-async/tree/session-support-1"

Bug Description

Unlike non-async / default Org Babel, evaluating the following code does not report an error in *Org-Babel Error Output* buffer (using switch-to-buffer-other-window)

raise NotImplementedError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment