Clarified question:
I have the following script which access web and local resources. I want to limit the web connections to N (the website is slow) and the local resources access (executeLocalNetworkProcess
) shouldn't block other web requests. (So it will always run N web requests).
Some categories have very little items while others have a lot. The parallel execution should be run for all items of all categories to utilize the web connectdions.
let categories = getCategories() // get a seq of category from web service
for c in categories do
getItemsByCategory c // returns a seq of item from web
|> Seq.iter (fun (item, _) -> // Want to process N items in parallel
getMoreDataFromWeb item // from web
executeLocalNetworkProcess item // local disk/network access; may take a while
downloadBigFile item // from web
)
What's the best approach to implement it in F#?