#SwiftLang #concurrency program stall question:
Given an array of urls to files the code does this:
// some prep code
await withTaskGroup { group in
var limit = min(urls.count, maxConcurrentTasks)
for ix in 0..<limit {
group.addTask { TypeInit(url: urls[ix]) }
}
for await type in group {
await doSomethingWith(type)
if limit < urls.count {
let url = urls[limit]
limit += 1
group.addTask { TypeInit(url: url }
}
}
}
// some other code never reached when the hang occurs
The issue is that when testing the code sometimes stops. No processor activity. The program is blocked waiting for something. I don't know what.
maxConcurrentTasks is currently 128 and is picked to get reasonable UI feedback. doSomethingWith(type) is not async but is on the MainActor. I've also used an explicit
await MainActor.run { doSomethingWith(type) }
No difference. (1/2)







