From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GB0lLRgmCmPT+gAAbAwnHQ (envelope-from ) for ; Sat, 27 Aug 2022 16:11:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CGITLRgmCmOaMQAA9RJhRA (envelope-from ) for ; Sat, 27 Aug 2022 16:11:36 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4362F29842 for ; Sat, 27 Aug 2022 16:11:36 +0200 (CEST) Received: from localhost ([::1]:54446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRwX9-0002xa-7X for larch@yhetil.org; Sat, 27 Aug 2022 10:11:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRwWd-0002xF-Ma for emacs-orgmode@gnu.org; Sat, 27 Aug 2022 10:11:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRwWc-0000zV-Dj for emacs-orgmode@gnu.org; Sat, 27 Aug 2022 10:11:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oRwWc-00054I-3u for emacs-orgmode@gnu.org; Sat, 27 Aug 2022 10:11:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#50514: 28.0.50; org inline call to python src block req C-g to break Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: emacs-orgmode@gnu.org Resent-Date: Sat, 27 Aug 2022 14:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50514 X-GNU-PR-Package: org-mode X-GNU-PR-Keywords: To: Lars Ingebrigtsen Cc: "Barton, Mark" , "50514@debbugs.gnu.org" <50514@debbugs.gnu.org>, Augusto Stoffel Received: via spool by 50514-submit@debbugs.gnu.org id=B50514.166160943619449 (code B ref 50514); Sat, 27 Aug 2022 14:11:02 +0000 Received: (at 50514) by debbugs.gnu.org; 27 Aug 2022 14:10:36 +0000 Received: from localhost ([127.0.0.1]:56719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRwWB-00053d-Gl for submit@debbugs.gnu.org; Sat, 27 Aug 2022 10:10:35 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:45891) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRwW8-00053M-Ip for 50514@debbugs.gnu.org; Sat, 27 Aug 2022 10:10:33 -0400 Received: by mail-pl1-f182.google.com with SMTP id u22so3976367plq.12 for <50514@debbugs.gnu.org>; Sat, 27 Aug 2022 07:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc; bh=8zCYWPJjhrjrgcyzYD8kMiLC9QzhCd4wjPBkQX1Wuuc=; b=RURF6klmz79Qh+UI5hTg9IHacc2k6EhN43lak9d/R2gqB1QuecJBA4krORTdmfG0xG /RA14bwpC9I2mgvrO2Jqum/q2koBMVy5lVthH2VQYHvz+eIazqv7cAADrnmvBwGkAsvE JwcTkSmIEn+aBXGUphiwUfnHn8wb2oSnHPK7jrtqomQq99wmDODbV7tGC9F2VzGFr4im 2wdM/gI7DrR/8fMcxEzzD8o0ej80WCJmZrwKB6FmVf441fFubLpB2bVhOl7bbTSzBPyz IFE1W6yh6fJlLU3b1BL8HIwosdM3TPsOA0DEaS3WLPQPpMNULpIuusfwaCriaNt0mNNz yK4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc; bh=8zCYWPJjhrjrgcyzYD8kMiLC9QzhCd4wjPBkQX1Wuuc=; b=TcFifzefHFNnNIkT7pXaLMi+hL33BE/6O6MXvZG+Z1SphL71XDE48cGuiIGLA8BYuQ G9xtFL2ZArmAr7Z4BxeeW3myMS98UNtwS3b3YuzOLc/6VSyz1/T1nt24HiFWE1U7MEXn atiMu52Pc16888GTFwK5jehKSljGFI07oSXtgas2ugJ2YbOTRwAqCC45unnBgucvj9Nd OtxfhZQyd3LLIPgd0gFoQmIF0WAeneaB6mrPOdFfBd+m7y7ucYi56/AjCSl6c1rcm/Lq Xt5E/eguhDXaQknmEZ3VEf+FpzPHvUE5Pzwlwq7aMdij/CnBgAoP1dYGttGGAv94lNZW Xoiw== X-Gm-Message-State: ACgBeo23p/0S0Sr0WjQB+KVaPw+oJPT/xLDcRnnn5RAhJHvLS1eD3NYg Rwza/1HMGZLKlfLFIeTbeSc= X-Google-Smtp-Source: AA6agR7Gzf8MowikRG6OEteAD9jOqVrwJQk35IeLWpLiqgG59Pw2AkaGTHFE23FKa1rGzjd7v/sViQ== X-Received: by 2002:a17:902:7087:b0:173:2a01:9ddb with SMTP id z7-20020a170902708700b001732a019ddbmr8132772plk.109.1661609426874; Sat, 27 Aug 2022 07:10:26 -0700 (PDT) Received: from localhost ([2409:8a70:2b3:c8a0:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id b2-20020a170902650200b00172ad9674e5sm2418372plk.291.2022.08.27.07.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Aug 2022 07:10:26 -0700 (PDT) From: Ihor Radchenko In-Reply-To: <875yidaks8.fsf@gnus.org> References: <24B9F777-2B69-45FD-ADBB-11E7A18F7A9A@disney.com> <87wnnnjlav.fsf@gmail.com> <871r5u1e3m.fsf@gmail.com> <61CB9513-0EEC-4F46-90D6-1D208BBADFA1@disney.com> <87pmteb1ef.fsf@gmail.com> <21C76818-63E5-4DC9-A60D-2BEF33813A18@disney.com> <73383502-159B-4BD9-8836-6C8A534A7063@disney.com> <87r1dry7x0.fsf@gmail.com> <32AF1DCB-F81A-4FB7-8EB2-31B483E5E468@disney.com> <87sfy7qadr.fsf@gmail.com> <073CC0D1-9900-4613-87E8-D69EA1C11623@disney.com> <87k0jjq79k.fsf@gmail.com> <87k0jiuuzc.fsf@gnus.org> <87mtbsgxwh.fsf@gnus.org> <875yifxhbm.fsf@localhost> <875yidaks8.fsf@gnus.org> Date: Sat, 27 Aug 2022 22:11:17 +0800 Message-ID: <87ler9epyy.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: emacs-orgmode@gnu.org List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661609496; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=8zCYWPJjhrjrgcyzYD8kMiLC9QzhCd4wjPBkQX1Wuuc=; b=ZnbEpg2sVr2EN8l4dDhcjjXOopWoc3sh5hEIJGufOzfGMNLt71sHxAx9IKRIFWU1zqVASJ JiLt47bkB9OiJG0UF/IDYvlhn+/lc38HIUPPQt86Yd//AbciuvSnGmglihR8DfIsyxG5ty SX6bqmcT4WpzYxYjSxcALW7rkNlhh+UEO0GxN7yT1/4yI7Xr5xKBT2lRKGaSGCEjvCsx5z +WqN+E0OWfZlZ99IAXtXgEVnLeGNQTVQg2KXKPILtSzQcfazCI5J/Iss4KsVv0BosfBCW1 zixtSbqKAJKP1rgDqWCEVmyLKURnhBxkuy4IOrFn9G1RaMwWwhjzujocU4+uJg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661609496; a=rsa-sha256; cv=none; b=OeQM6ZJbeOHkIU8kQnBmOm70dYf09W2FBzkeHFGTGWEvSGkmJybuWFAKCNwsSzaupzjPoG IjTMiWGwYrpCkLJKtbE9HH0d8wKJ+bp3vVvr+pY3FF3eVqYaebfBON/VfUfyc8I4hXUktv WYCpVi0IPhPi4Tt8AhZKXurxSNa9ltDS0lH2LB1y4v2orpJBkvns+eGlFQ/3DqvtSKkrwL NNypUM2Luf2MOk9pZaivJeAskERluNU6UkLlOUMZIOZ82HYqYZ+5B1b3j8ezuLk2uYvgyV b+tqmyVDeeBaky+bzD1tzeLpsBDh+3vgtWzDja4sXBExOIOHjhJcoaPUejih4g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=RURF6klm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.60 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=RURF6klm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 4362F29842 X-Spam-Score: 5.60 X-Migadu-Scanner: scn0.migadu.com X-TUID: Hrtn8NQu/RgI --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Lars Ingebrigtsen 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 =E2=80=9Cfixed=E2=80=9D. > > 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? --=20 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-python-Fix-Emacs-bug-50514-when-Python-loads-slow.patch >From d5347c688d2fb8037116d82fa7987e9e6690ae66 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko 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 --=-=-=--