From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp2.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms8.migadu.com with LMTPS
	id EP4HJhI8wGVHbAAAe85BDQ:P1
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 05 Feb 2024 02:38:26 +0100
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp2.migadu.com with LMTPS
	id EP4HJhI8wGVHbAAAe85BDQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 05 Feb 2024 02:38:26 +0100
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20230601 header.b=Zkxb3mVL;
	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=1707097106;
	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=3FtFYHO2gA8EazkMGuxlqdv6w56B1IvYoYu9PhoH7NE=;
	b=T3Xbj+l8hoOSUVDXV3/IwEWfGCcitBmNbLyBC7Vuzxk8n1L1F9Z/Fvhh+ytXBL262Srlzr
	zKKuFHtThtddCz37lYDsGPGAFqemRvCvsbqa02gkMzZnzD7Dp6f420rWbw4F+DPfj2Wsxv
	3ub4DO5q6ZZqynpLDzBIMGnU9EWcNQVOnNX/2Y1n/odbFWeyPXVTakJXbvWHvL8V3iMgmr
	tEnXPFk8dc2K4wYBDtCP3M1WFM/LBtYVOsRUtyncWSZjBPnJVe1Eq8DoazpL3G2oA9TNxK
	cNLPzzA8yQgF+hYDZYuTk56FXQZgE1J9mqpWHTYVqLea/DGSMEnbMJXS50h0lQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=gmail.com header.s=20230601 header.b=Zkxb3mVL;
	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=1707097106; a=rsa-sha256; cv=none;
	b=IKXZZ1guOWOJuoj/22n0bgD4ZKsyuQ8my8tp3lazNmr8TIP6wP9F/407Vao+jFZGWTO7dB
	ww6/pAJhj1AHItIM71p4bfcikJ5BqzM2uL7XBrb4BW/GL5D/uv/M2blhfvTbhuvV+R5V5M
	WMzjYcMdDBQsrccAxVkLyPQ5xiCrctWR9f00cxVJ4pqibW+Y40tRXnWif3vOKq0mzwNT1j
	eqHWRY3T98dyST3LHF9rjuA3PPhISlXUUPyF6miVbihTi48U9+NVbSUEs7pSGqrxXJbKZi
	NW8KY5JN/B4GW6Sow9vLz9FTyAKSdclMcjucdk9EeYFfMtb3vo5BvrYgraa6Ag==
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 4278C3A7B0
	for <larch@yhetil.org>; Mon,  5 Feb 2024 02:38:26 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1rWnvG-00022G-6N; Sun, 04 Feb 2024 20:37:22 -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 <jackkamm@gmail.com>)
 id 1rWnvE-000224-Tt
 for emacs-orgmode@gnu.org; Sun, 04 Feb 2024 20:37:20 -0500
Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <jackkamm@gmail.com>)
 id 1rWnvD-0001CF-45
 for emacs-orgmode@gnu.org; Sun, 04 Feb 2024 20:37:20 -0500
Received: by mail-pj1-x102d.google.com with SMTP id
 98e67ed59e1d1-29685114bc3so289873a91.3
 for <emacs-orgmode@gnu.org>; Sun, 04 Feb 2024 17:37:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1707097037; x=1707701837; darn=gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=3FtFYHO2gA8EazkMGuxlqdv6w56B1IvYoYu9PhoH7NE=;
 b=Zkxb3mVLRfp0p48gqQ1a4gIa3PJ3SmDjBavABjzEXaUAywwCvjM6D3ud/BY4p+L+9b
 m8jO4+EBz2GKMK7Nw0/JPg46u9aKDTOfJlfFrGWLhf2BqjLrHh7AKbmBlzAQ+cadTA5z
 UCsIGxyxfvE8kIWc8Rf15BvM7wBceEM5gOLVednSviFYdwP5LfEh6vqzGyTOvCIKQ4Ty
 A9TCJCg0qXUU/jn0G/353EHimXxlN3iRruSPGjL39qPh5Z7J1wa/LbBzwuhOL1q2D4TM
 N03BtA2z1FQ79DmRoxISOlHWli8Entj1xbv6ZqgW9q0cE4qAlh4vo7zYEOVQQJc42eOu
 kaTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1707097037; x=1707701837;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=3FtFYHO2gA8EazkMGuxlqdv6w56B1IvYoYu9PhoH7NE=;
 b=LR61fwSd1P/ggdH4nGkOhpFFNqvWlejvs8815aWJ4EP7mq41wyt9oQ2dTsKJeXvSeQ
 XAtZrlaDmfEJ+b7tHHTidQtiXZm0yVUVb86S5P5QDvXSGEEO9Wk/BmvWf9hsGXlnezjy
 kyMVlI85APRzFb3JiJgDcifDdX6L58BxPJS0ciBSYO86WGuk7vIdMs0fXXyAOLwT7CPN
 +dAJroDGt0PsjcLTlpYo8BQKB8m+pKCcGnZG0oeWuag9ZHvA/i5tnNAe8qHEwx77ASZL
 EqZzvrLxqXb8tBJE0AIZZC1ZaaMj9qtq5MdItWnhAUN06H8fi7Q+I1iJ77EqQI7tVK59
 lLDw==
X-Gm-Message-State: AOJu0YwezNOMyENCQnkUDufMcmo2qZ2AxeK1PH2De0nz3bzbg2W6ra08
 ZyHbRoDe7nRRb0CMAapoxWTywM+XA8uYC+7N6w2RE7UQCZbJjU1P
X-Google-Smtp-Source: AGHT+IHZd+KSF8Y6hpWTB4yGwOZ3IKhIW0293713ue82uIXDqmDu3lVJlTeqS/LF/LTOCE8fBMII4w==
X-Received: by 2002:a17:90b:4b48:b0:296:6a36:a615 with SMTP id
 mi8-20020a17090b4b4800b002966a36a615mr2893307pjb.34.1707097037274; 
 Sun, 04 Feb 2024 17:37:17 -0800 (PST)
X-Forwarded-Encrypted: i=0;
 AJvYcCXg0gyvYXkNNb53AA7K+TDQCFV5ARw+HPCgyGvidGI+xPDSCNOXPT12z3RjlaEDim93UHaPpzB/9JdWmhlrdD6bAWbW9Bs=
Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net.
 [157.131.78.143]) by smtp.gmail.com with ESMTPSA id
 qd14-20020a17090b3cce00b00296715e391dsm2651309pjb.24.2024.02.04.17.37.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 04 Feb 2024 17:37:16 -0800 (PST)
From: Jack Kamm <jackkamm@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Bruno Barbier <brubar.cs@gmail.com>, 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: <875xz42rp9.fsf@localhost>
References: <87o7d0mm54.fsf@localhost>
 <65bbb108.050a0220.b60fd.6790@mx.google.com> <87jznm8hcu.fsf@gmail.com>
 <875xz42rp9.fsf@localhost>
Date: Sun, 04 Feb 2024 17:37:15 -0800
Message-ID: <874jen8zec.fsf@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::102d;
 envelope-from=jackkamm@gmail.com; helo=mail-pj1-x102d.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,
 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." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=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: -8.21
X-Migadu-Queue-Id: 4278C3A7B0
X-Spam-Score: -8.21
X-Migadu-Scanner: mx11.migadu.com
X-TUID: IGkJnrEYlpUy

Ihor Radchenko <yantar92@posteo.net> writes:

> Jack Kamm <jackkamm@gmail.com> writes:
>
>> I think the correct solution would be for `org-babel-insert-result' to
>> not insert file results (or any other special results) for async session
>> blocks.  Perhaps in this case, `org-babel-insert-result' could return a
>> new result type, named "async", "future", or similar.
>
> That will not work.
> `org-babel-comint-async-filter' expects a unique result to be inserted
> into Org buffer, so that it can be located, and replaced by the async
> evaluation output.
>
> So, we have to insert some kind of indicator for async result.

I meant that we could return something like "async:uuid-abcd-1234" or
"async:/path/to/tmpfile", so that `org-babel-comint-async-filter' could
still find the result.

> Of course, the existing scheme of coordination between
> `org-babel-insert-result' and `org-babel-comint-async-filter' is
> erroneous:
>
> 1. We have the problem with :results file value discussed here
> 2. We have a worse problem with :results file :file foo when the result
>    may not be unique
> 3. We have :results append/prepend completely broken because
>    `org-babel-comint-async-filter' simply calls
>    `org-babel-insert-result' implicitly assuming that the existing
>    indicator is replaced.
>
> The whole thing should be re-designed.

I agree that it would be good to redesign it, but am not sure where to
start.

A bit of a tangent, but if you are thinking about re-designing this,
then it may be worth considering ob-jupyter's implementation of async
sessions [1]. In particular, I believe it leaves a marker [2] where it
needs to insert the future result. I don't remember the details,
e.g. how it keeps track of which marker is for which result. But it
seems neat, and might work better for some cases such as
appending/prepending results.

[1] https://github.com/emacs-jupyter/jupyter
[2] https://www.gnu.org/software/emacs/manual/html_node/elisp/Markers.html