From 1504187949350295af8497859d8210130c851e1d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 17 Oct 2024 19:09:13 +0100 Subject: [PATCH] Update src/trio/_core/_asyncgens.py --- src/trio/_core/_asyncgens.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trio/_core/_asyncgens.py b/src/trio/_core/_asyncgens.py index 76963a352..6bb6ceeed 100644 --- a/src/trio/_core/_asyncgens.py +++ b/src/trio/_core/_asyncgens.py @@ -83,9 +83,10 @@ def finalizer(agen: AsyncGeneratorType[object, NoReturn]) -> None: agen_name = name_asyncgen(agen) try: self.foreign.remove(id(agen)) - is_ours = False except KeyError: is_ours = True + else: + is_ours = False if is_ours: runner.entry_queue.run_sync_soon(