Scala: infinite duration / timeout for Futures

For whatever reason, a lot of blog posts I’ve seen put timeouts on Futures, and it took me some time to find the “infinite” one.

If you want to do this, here is what you need:

import scala.concurrent.duration.Duration

val tasks = for (thread <- 1 to 10) yield Future {
  doSomething
}

val aggr = Future.sequence(tasks)

Await.result(aggr, Duration.Inf)

Leave a Reply

Your email address will not be published. Required fields are marked *