From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id cBUGBp+HwmWK7wAAe85BDQ:P1 (envelope-from ) for ; Tue, 06 Feb 2024 20:25:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id cBUGBp+HwmWK7wAAe85BDQ (envelope-from ) for ; Tue, 06 Feb 2024 20:25:19 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hKHb5KZ5; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707247518; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=YFyS2MgYwgysjCS5voqCh38f3zyV7lpDAqO+HZTGszs=; b=N2uUs7LbxkGOHpOia8I+FWazZ3tiaqv8OZ87Kgq9dU8fd6Pj6tULDgrUahhg/7eDsewJmU K0V4tddbM4GB4+M+64YcaNjOB86I2FmdbWP+4AA9weaZESUgxx5CeIqv8MO0aGjJ5jYU02 LeGNNJvne5KXFz9maG498PhnQ+YYDI/AusWP+GQRa7DU/IIMwF/M+neJ/PXtZVumD4r9DT /OjPkrpSZRhSyBxTpDg0C/pxTFym3ZwLMCwg4VJr3ttOLgVaPYel79VS/3Bj8dbTr89IN4 F6yTR8iH64VK4CcD93D01f25L5iTuVOMa1QA8BxjIyyzguSf6hNLHAU9nq7low== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hKHb5KZ5; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707247518; a=rsa-sha256; cv=none; b=N+IsiEqUq4vN/exi4E5ELq94N60PYfqxQ/YCRQKS6g3Oi9/3LZgCqQZDK/8F+2sRmZDfIa yoX5EGb53PqpcnfeNT+Kgq4vKSyvAoQN77r4UCK51H16FaqVOBx4hjk8RyNYg6Qvz9irWn +R1AidtSONkTaPbkATNG+S+xhtL67AHxKYe4IHRvLdMYPCOjfbaBa0JI7R+gY17Ljgx+s0 x8VjWq2nQVMBtOpbLS4WQvyZfxztUqJT33JmUgigV5RRIH6xbK+zUMyc/TE82QIg6N4Ytd CZgCWEjodAVNWG/krQYHwjOWimyGTL0wQDf74Y9J59gkhNH3vyxAEWPyoOVwNg== 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 DB5AD56F61 for ; Tue, 6 Feb 2024 20:25:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXR3N-0008Q5-7z; Tue, 06 Feb 2024 14:24:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXR3L-0008Pw-G8 for emacs-orgmode@gnu.org; Tue, 06 Feb 2024 14:24:19 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXR3J-0003wg-NP for emacs-orgmode@gnu.org; Tue, 06 Feb 2024 14:24:19 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40fc654a718so40434295e9.2 for ; Tue, 06 Feb 2024 11:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707247456; x=1707852256; darn=gnu.org; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=YFyS2MgYwgysjCS5voqCh38f3zyV7lpDAqO+HZTGszs=; b=hKHb5KZ5kwK25W1Sl96BxAE9/v/RO63gFLQ3U/Mj0JpX25Clr3PmnQN0r0ycoQRn2O 2BpEnv26Lb3hu8us1OPM25LQL0E8o0+G3fcNDQ0c3xHDvofhfcruMIQ27Q//RS7szpC5 jJxVCM/v7xYSEzKCa39ReneuYYI4uv3yIXliriAqgcdEACBJ8HhBFExGJ24Synmgwda+ ErzCU9XVWU0uf8CAYYsmFIo9w/QNJ0Y8rjIiOpOCb5paPst0oSbjrbB5oHkmC4+7+PEg kbxXZhKp3Nloi/1+kr8qA2+O0tulCTAON6ypCcG+i25C6s7luRR3+Iok4ymAHhtVAs2D C/Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707247456; x=1707852256; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YFyS2MgYwgysjCS5voqCh38f3zyV7lpDAqO+HZTGszs=; b=SMtvmnbtVBtAUeJlbjyZXAR25aTiNFSsMdfh5e56xARgB5B12ZKygB7zp/aSx83U9e NgWrLCE2mY8R7+IvvvLORNrIaQm0y18fecA5wYyKvevm3tzfYtBLr7DEuAa9wjZQ3LsX fl56cs/IoVXkiq6gGaL5hvXuju/bmylugc4yFzWIBp+52JfTj2Mv4FPQBEQeZkF/GS3e 3M1A/jsabl5mxC3Mffw1HiYsJT2WFUHmUpIjGKRPJ1O4qSXOzh01uQmakuj9pYkM0HJ8 DxPM55suG0XD7wHYo7nyTZLqaeVwCMOZePsYCTO25dnZQjLYs6ofOk9TrLR18Ro3yFKP sK5w== X-Gm-Message-State: AOJu0YxzQqJb14GuyN06aeGojRgJuA9KNLStCZMYhsLQo3TvI145vCct BtTwif3JjPFSWh5KZm0qJPzKCZQMJo6a7qIAT5tHw/Ztuh1nFmKC X-Google-Smtp-Source: AGHT+IE1BVyaYUiMIIy7uMEmAvU0oEhnzFL6WkyPLxYypb/5U0Sz9WuY+9ZzHdA8ZLE3ZN3DWJIY9Q== X-Received: by 2002:a05:600c:4f54:b0:40f:dc51:1882 with SMTP id m20-20020a05600c4f5400b0040fdc511882mr2963471wmq.8.1707247455646; Tue, 06 Feb 2024 11:24:15 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUsgoBfAJKa6cD9z58MxYRFTCtZ8+vKP18We9t231KByK66XB6zWv9XGdMN39S7tyzCfeDLwO1xv5FiONYyFr+9FSY= Received: from keynux ([2a01:e0a:505:3460:1c18:688d:ece4:372e]) by smtp.gmail.com with ESMTPSA id m31-20020a05600c3b1f00b0040ff7e3170asm904201wms.2.2024.02.06.11.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:24:15 -0800 (PST) Message-ID: <65c2875f.050a0220.caf6d.8291@mx.google.com> Received: by keynux (sSMTP sendmail emulation); Tue, 06 Feb 2024 20:24:13 +0100 From: Bruno Barbier To: Ihor Radchenko , Jack Kamm Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] Unexpected result when evaluating python src block asynchronously [9.7-pre (release_9.6.17-1131-gc9ed03.dirty @ /home/yantar92/.emacs.d/straight/build/org/)] In-Reply-To: <87o7cv9e80.fsf@localhost> References: <87o7d0mm54.fsf@localhost> <65bbb108.050a0220.b60fd.6790@mx.google.com> <87jznm8hcu.fsf@gmail.com> <875xz42rp9.fsf@localhost> <874jen8zec.fsf@gmail.com> <87o7cv9e80.fsf@localhost> Date: Tue, 06 Feb 2024 20:24:13 +0100 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=brubar.cs@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -7.01 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -7.01 X-Migadu-Queue-Id: DB5AD56F61 X-TUID: kTvGnL7ksDK/ Hi Ihor, Jack, Ihor Radchenko writes: > Jack Kamm writes: > >> I agree that it would be good to redesign it, but am not sure where to >> start. > > For example, > > 1. Change `org-babel-comint-async-register' to return UUID and to store > PARAMS as passed by the backend (current approach with PARAMS being > derived from src blocks prevents backends to transform src block > PARAMS dynamically). > 2. Change `org-babel-insert-result' to handle :async t specially, > inserting something reliable, like #+async: in place of result > without performing extra transformations. > 3. Change `org-babel-insert-result' to accept an internal parameter > that will make it replace #+async: keyword rather than perform > normal result insertion. > 4. Change `org-babel-comint-async-filter' to use the previously passed > PARAMS, remove :async t from them, and arrange the call to > `org-babel-insert-result' to replace the #+async: keyword. > FWIW, I've been trying to use asynchronous blocks for everything, not only the source blocks that are based on the comint mode. I think it would be good if ob-core itself could provide an asynchronous API. I've modified my Org so that it does have such an API. This is work in progress; let me describe it. I've modified ob-core itself to allow asynchronicity. In the asynchrosous case, instead of calling: (org-babel-execute:LANG body params) I'm calling: (org-babel-schedule:LANG body params handle-result) where `org-babel-schedule:LANG' is in charge of calling `handle-result' with the result (or the error) when it is known; `handle-result' takes care to call `org-babel-insert-result' at the correct place (and `org-babel-insert-result' is only called with a real result). While the execution is pending, I'm using the same technique that Org is using when a source block is being edited: the result is left untouched, but below an overlay. The overlay is used to know where to insert the result and to display the status/progress of the execution. If the file is closed and the execution fails, nothing is lost, the old result is still available. If that technique looks safe enough and interesting, I can prepare a set of patches so that we can discuss it further and, maybe, add it in Org. Let me know, Thanks, Bruno