Skip to content

Commit

Permalink
async
Browse files Browse the repository at this point in the history
  • Loading branch information
hamelsmu committed Oct 12, 2024
1 parent 3957748 commit ccde11e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fastcore/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async def limited_task(item):
return await asyncio.wait_for(coro, timeout) if timeout else await coro

tasks = [limited_task(item) for item in items]
return asyncio.gather(*tasks)
return await asyncio.gather(*tasks)

# %% ../nbs/03a_parallel.ipynb
def run_procs(f, f_done, args):
Expand Down
24 changes: 12 additions & 12 deletions nbs/03a_parallel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0 2024-10-11 21:08:04.678835\n",
"1 2024-10-11 21:08:04.930711\n",
"2 2024-10-11 21:08:05.181549\n",
"3 2024-10-11 21:08:05.435812\n",
"4 2024-10-11 21:08:05.687301\n"
"0 2024-10-11 23:06:05.920741\n",
"1 2024-10-11 23:06:06.171470\n",
"2 2024-10-11 23:06:06.431925\n",
"3 2024-10-11 23:06:06.689940\n",
"4 2024-10-11 23:06:06.937109\n"
]
}
],
Expand Down Expand Up @@ -539,7 +539,7 @@
" return await asyncio.wait_for(coro, timeout) if timeout else await coro\n",
"\n",
" tasks = [limited_task(item) for item in items]\n",
" return asyncio.gather(*tasks)"
" return await asyncio.gather(*tasks)"
]
},
{
Expand All @@ -560,12 +560,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2 2024-10-11 21:08:23.196473 0.28277557322761593\n",
"1 2024-10-11 21:08:23.258949 0.3449957623467014\n",
"0 2024-10-11 21:08:23.341502 0.4269314183522479\n",
"5 2024-10-11 21:08:23.665180 0.3214516296250627\n",
"3 2024-10-11 21:08:23.814849 0.6164311736352199\n",
"4 2024-10-11 21:08:23.864115 0.6032399559625771\n"
"0 2024-10-11 23:06:39.545583 0.10292732609738675\n",
"3 2024-10-11 23:06:39.900393 0.3516179734831676\n",
"4 2024-10-11 23:06:39.941094 0.03699593757956876\n",
"2 2024-10-11 23:06:39.957677 0.5148658606540902\n",
"1 2024-10-11 23:06:40.099716 0.6574035385815227\n",
"5 2024-10-11 23:06:40.654097 0.7116319667399102\n"
]
}
],
Expand Down

0 comments on commit ccde11e

Please sign in to comment.