Skip to content

Commit 5fc947b

Browse files
committedApr 18, 2024
Prevent executing a source block already being executed
* ob-jupyter.el (org-babel-execute:jupyter): Do it. * test/jupyter-test.el (org-babel-prevent-multiple-executions): New test.
1 parent 51799ec commit 5fc947b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎ob-jupyter.el

+5
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ These parameters are handled internally."
529529
"Execute BODY according to PARAMS.
530530
BODY is the code to execute for the current Jupyter `:session' in
531531
the PARAMS alist."
532+
(when org-babel-current-src-block-location
533+
(save-excursion
534+
(goto-char org-babel-current-src-block-location)
535+
(when (jupyter-org-request-at-point)
536+
(user-error "Source block currently being executed"))))
532537
(let* ((result-params (assq :result-params params))
533538
(async-p (jupyter-org-execute-async-p params)))
534539
(when (member "replace" result-params)

‎test/jupyter-test.el

+15
Original file line numberDiff line numberDiff line change
@@ -3102,6 +3102,21 @@ raise Exception(\"This is an error\")
31023102
(sleep-for 0.1))
31033103
(funcall check-result ": 6")))))
31043104

3105+
(ert-deftest org-babel-prevent-multiple-executions ()
3106+
:tags '(org q)
3107+
(let ((src (format "\
3108+
#+BEGIN_SRC jupyter-python :session %s :async yes
3109+
1
3110+
#+END_SRC
3111+
"
3112+
jupyter-org-test-session)))
3113+
(jupyter-org-test
3114+
(insert src)
3115+
(org-previous-block 1)
3116+
(org-babel-execute-src-block)
3117+
(should (jupyter-org-request-at-point))
3118+
(should-error (org-babel-execute-src-block)))))
3119+
31053120
;; Local Variables:
31063121
;; byte-compile-warnings: (unresolved obsolete lexical)
31073122
;; eval: (and (functionp 'aggressive-indent-mode) (aggressive-indent-mode -1))

0 commit comments

Comments
 (0)
Please sign in to comment.