Function: org-babel-python-async-evaluate-session

org-babel-python-async-evaluate-session is a byte-compiled function defined in ob-python.el.gz.

Signature

(org-babel-python-async-evaluate-session SESSION BODY &optional RESULT-TYPE RESULT-PARAMS GRAPHICS-FILE)

Documentation

Asynchronously evaluate BODY in SESSION.

Returns a placeholder string for insertion, to later be replaced by org-babel-comint-async-filter.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-python.el.gz
(defun org-babel-python-async-evaluate-session
    (session body &optional result-type result-params graphics-file)
  "Asynchronously evaluate BODY in SESSION.
Returns a placeholder string for insertion, to later be replaced
by `org-babel-comint-async-filter'."
  (org-babel-comint-async-register
   session (current-buffer)
   "ob_comint_async_python_\\(start\\|end\\|file\\)_\\(.+\\)"
   'org-babel-chomp 'org-babel-python-async-value-callback)
  (pcase result-type
    (`output
     (let ((uuid (org-id-uuid)))
       (with-temp-buffer
         (insert (format org-babel-python-async-indicator "start" uuid))
         (insert "\n")
         (insert (if graphics-file
                     (format org-babel-python--output-graphics-wrapper
                             body graphics-file)
                   body))
         (insert "\n")
         (insert (format org-babel-python-async-indicator "end" uuid))
         (let ((python-shell-buffer-name
                (org-babel-python-without-earmuffs session)))
           (python-shell-send-buffer)))
       uuid))
    (`value
     (let ((results-file (or graphics-file
			     (org-babel-temp-file "python-")))
           (tmp-src-file (org-babel-temp-file "python-")))
       (with-temp-file tmp-src-file (insert body))
       (with-temp-buffer
         (insert (org-babel-python-format-session-value
                  tmp-src-file results-file result-params))
         (insert "\n")
         (unless graphics-file
           (insert (format org-babel-python-async-indicator "file" results-file)))
         (let ((python-shell-buffer-name
                (org-babel-python-without-earmuffs session)))
           (python-shell-send-buffer)))
       results-file))))