all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Barton, Mark" <Mark.Barton@disney.com>,
	"50514@debbugs.gnu.org" <50514@debbugs.gnu.org>,
	Augusto Stoffel <arstoffel@gmail.com>
Subject: bug#50514: 28.0.50; org inline call to python src block req C-g to break
Date: Sat, 27 Aug 2022 22:11:17 +0800	[thread overview]
Message-ID: <87ler9epyy.fsf@localhost> (raw)
In-Reply-To: <875yidaks8.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> Could you please elaborate what the problem is?
>> There have been multiple issues in this thread and the one previously
>> reported to Org ML is solved on Emacs side.
>
> It's this bit:
>
>> So I found if I extend the sleep-for in ob-python from 10 ms to 90 ms,
>> my initialization problem is “fixed”.
>
> The sleep is still 10ms in the in-tree ob-python, at least.

10ms magic constant is indeed not great.
However, I am unable to reproduce the original bug on my system.
I tried to draft an alternative patch. See the attached.

Mark, would you mind testing the patch?

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-python-Fix-Emacs-bug-50514-when-Python-loads-slow.patch --]
[-- Type: text/x-patch, Size: 1820 bytes --]

From d5347c688d2fb8037116d82fa7987e9e6690ae66 Mon Sep 17 00:00:00 2001
Message-Id: <d5347c688d2fb8037116d82fa7987e9e6690ae66.1661609451.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 27 Aug 2022 22:06:11 +0800
Subject: [PATCH] ob-python: Fix Emacs bug#50514 when Python loads slowly

* lisp/ob-python.el (org-babel-python-initiate-session): Wait until
python process is initialized.
(org-babel-python-initiate-session-by-key): Do not rely on 10ms delay
to initialize Python.
---
 lisp/ob-python.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 932aca08e..2ad907bd8 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -197,8 +197,7 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 	  (setq py-buffer (org-babel-python-with-earmuffs session)))
 	(let ((python-shell-buffer-name
 	       (org-babel-python-without-earmuffs py-buffer)))
-	  (run-python cmd)
-	  (sleep-for 0 10)))
+	  (run-python cmd)))
        ((and (eq 'python-mode org-babel-python-mode)
 	     (fboundp 'py-shell)) ; python-mode.el
 	(require 'python-mode)
@@ -225,8 +224,9 @@ (defun org-babel-python-initiate-session-by-key (&optional session)
 (defun org-babel-python-initiate-session (&optional session _params)
   "Create a session named SESSION according to PARAMS."
   (unless (string= session "none")
-    (org-babel-python-session-buffer
-     (org-babel-python-initiate-session-by-key session))))
+    (let ((session (org-babel-python-session-buffer
+                    (org-babel-python-initiate-session-by-key session)))))
+    (org-babel-comint-wait-for-output session)))
 
 (defvar org-babel-python-eoe-indicator "org_babel_python_eoe"
   "A string to indicate that evaluation has completed.")
-- 
2.35.1


  reply	other threads:[~2022-08-27 14:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 23:06 bug#50514: 28.0.50; org inline call to python src block req C-g to break Barton, Mark
2021-09-11 13:04 ` Lars Ingebrigtsen
2021-09-11 13:26 ` Augusto Stoffel
2021-09-12  6:22   ` Barton, Mark
2021-09-12  6:51     ` Augusto Stoffel
2021-09-12  8:27       ` Barton, Mark
2021-09-12  9:15         ` Augusto Stoffel
2021-09-12 17:00           ` Barton, Mark
2021-09-12 20:04             ` Barton, Mark
2021-09-14  6:42               ` Augusto Stoffel
2021-09-14 17:54                 ` Barton, Mark
2021-09-14 18:29                   ` Augusto Stoffel
2021-09-14 19:25                     ` Barton, Mark
2021-09-14 19:31                       ` Augusto Stoffel
2021-09-14 22:20                         ` Barton, Mark
2021-09-15  6:28                           ` Augusto Stoffel
2021-09-14 19:36                       ` Augusto Stoffel
2021-09-15  8:02                         ` Lars Ingebrigtsen
2022-08-25 15:12                           ` Lars Ingebrigtsen
2022-08-26 13:30                             ` Ihor Radchenko
2022-08-27 13:16                               ` Lars Ingebrigtsen
2022-08-27 14:11                                 ` Ihor Radchenko [this message]
2022-08-27 18:56                                   ` Barton, Mark
2022-08-27 21:31                                     ` Mark Barton
2022-08-28  0:38                                       ` Barton, Mark
2022-08-28  1:30                                         ` Ihor Radchenko
2022-08-28  1:56                                           ` Barton, Mark
2022-08-28  2:55                                             ` Ihor Radchenko

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ler9epyy.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=50514@debbugs.gnu.org \
    --cc=Mark.Barton@disney.com \
    --cc=arstoffel@gmail.com \
    --cc=larsi@gnus.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.