File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ from asyncio import gather
1
2
from inspect import isawaitable
2
3
from typing import (
3
4
Any ,
@@ -427,6 +428,7 @@ def execute_fields(
427
428
)
428
429
if result is not INVALID :
429
430
results [response_name ] = result
431
+
430
432
if not is_async and isawaitable (result ):
431
433
is_async = True
432
434
@@ -437,11 +439,18 @@ def execute_fields(
437
439
# Otherwise, results is a map from field name to the result of
438
440
# resolving that field, which is possibly a coroutine object.
439
441
# Return a coroutine object that will yield this same map, but with
440
- # any coroutines awaited and replaced with the values they yielded.
442
+ # any coroutines awaited in parallel and replaced with the values they
443
+ # yielded.
441
444
async def get_results ():
445
+ async def await_kv (key , value ):
446
+ return key , await value if isawaitable (value ) else value
447
+
442
448
return {
443
- key : await value if isawaitable (value ) else value
444
- for key , value in results .items ()
449
+ key : value
450
+ for key , value in await gather (
451
+ * (await_kv (key , value ) for key , value in results .items ()),
452
+ return_exceptions = True ,
453
+ )
445
454
}
446
455
447
456
return get_results ()
You can’t perform that action at this time.
0 commit comments