From f25559c9d76816deb0395993fdc983f40b9d2078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 13 Nov 2024 02:22:53 +0200 Subject: [PATCH] Minor optimizations --- src/anyio/_backends/_asyncio.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/anyio/_backends/_asyncio.py b/src/anyio/_backends/_asyncio.py index fb07853b..2649078d 100644 --- a/src/anyio/_backends/_asyncio.py +++ b/src/anyio/_backends/_asyncio.py @@ -895,15 +895,13 @@ def task_done(_task: asyncio.Task) -> None: name = get_callable_name(func) if name is None else str(name) try: task = create_task(coro, name=name) - except BaseException: + finally: del _task_states[coro] - raise + _task_states[task] = task_state self.cancel_scope._tasks.add(task) self._tasks.add(task) - del _task_states[coro] - _task_states[task] = task_state if task.done(): # This can happen with eager task factories task_done(task)