File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -526,17 +526,24 @@ object `package` extends mill.Module {
526
526
527
527
// Try to fetch all the links serially. It isn't worth trying to parallelize it
528
528
// because if we go too fast the remote websites tend to rate limit us anyway
529
- val linksToStatusCodes = allLinks.toSeq.zipWithIndex
529
+ val linksToStatusCodesFut = allLinks.toSeq.zipWithIndex
530
530
.map { case (link, i) =>
531
531
val key = s"$i/${allLinks.size}"
532
- println(s"Checking link $link $key")
533
- val start = System.currentTimeMillis()
534
- val res = requests.head(link, check = false).statusCode
535
- val duration = System.currentTimeMillis() - start
536
- val remaining = 1000 - duration
537
- if (remaining > 0) Thread.sleep(remaining) // try to avoid being rate limited
538
- (link, res)
532
+ Task.fork.async(
533
+ dest = Task.dest,
534
+ key = key,
535
+ message = s"Checking link $link"
536
+ ) { logger =>
537
+ val start = System.currentTimeMillis()
538
+ val res = requests.head(link, check = false).statusCode
539
+ val duration = System.currentTimeMillis() - start
540
+ val remaining = 1000 - duration
541
+ if (remaining > 0) Thread.sleep(remaining) // try to avoid being rate limited
542
+ (link, res)
543
+ }
539
544
}
545
+
546
+ val linksToStatusCodes = Task.fork.awaitAll(linksToStatusCodesFut)
540
547
.toMap
541
548
542
549
allLinksAndAnchors()
You can’t perform that action at this time.
0 commit comments