Whats the best way to download multiple files in coroutines with a fixed amount of parallel downloads. So there are like 1000 files and I want to download them in parallel but only 4 at a time
t
tseisel
06/05/2022, 5:00 PM
You probably want to take a look at coroutines Semaphore. You could also create 4 "download file" actors and fan out using channels.
j
jw
06/05/2022, 5:08 PM
Yep. Channel + repeat(4) { launch{ download() } }. Shove all 1000 URLs into the channel.
This won't stop them all being started at once. Just stop the CPU intensive bits from running concurrently. The network bits will happily go 1000 at once.