Skip to content

Commit 161e739

Browse files
committed
FIX: Ensure coroutines are converted to tasks prior to asyncio.wait
1 parent 1cde34e commit 161e739

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pydra/engine/workers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ async def fetch_finished(self, futures):
5858
done = set()
5959
try:
6060
done, pending = await asyncio.wait(
61-
futures, return_when=asyncio.FIRST_COMPLETED
61+
[
62+
asyncio.create_task(f) if not isinstance(f, asyncio.Task) else f
63+
for f in futures
64+
],
65+
return_when=asyncio.FIRST_COMPLETED,
6266
)
6367
except ValueError:
6468
# nothing pending!
@@ -105,7 +109,11 @@ async def fetch_finished(self, futures):
105109
try:
106110
self._jobs += len(futures)
107111
done, pending = await asyncio.wait(
108-
futures, return_when=asyncio.FIRST_COMPLETED
112+
[
113+
asyncio.create_task(f) if not isinstance(f, asyncio.Task) else f
114+
for f in futures
115+
],
116+
return_when=asyncio.FIRST_COMPLETED,
109117
)
110118
except ValueError:
111119
# nothing pending!

0 commit comments

Comments
 (0)