From fd9258f6a9231858fb62478a95f5f624fca32259 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 16 Nov 2021 19:48:09 -0800 Subject: [PATCH] Fix for Python 3.6, refs #1 --- asyncinject/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/asyncinject/__init__.py b/asyncinject/__init__.py index 3cac54e..b18492b 100644 --- a/asyncinject/__init__.py +++ b/asyncinject/__init__.py @@ -114,18 +114,16 @@ async def resolve(instance, names, results=None): ts.done(*node_group) for node_group in plan: + awaitable_names = [name for name in node_group if name in instance._registry] awaitables = [ instance._registry[name]( instance, _results=results, **{k: v for k, v in results.items() if k in instance._graph[name]}, ) - for name in node_group - if name in instance._registry + for name in awaitable_names ] awaitable_results = await asyncio.gather(*awaitables) - results.update( - {p[0].__name__: p[1] for p in zip(awaitables, awaitable_results)} - ) + results.update(dict(zip(awaitable_names, awaitable_results))) return results