{"id":3546,"date":"2016-04-06T01:07:04","date_gmt":"2016-04-06T01:07:04","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3546"},"modified":"2016-04-06T01:07:04","modified_gmt":"2016-04-06T01:07:04","slug":"scala-infinite-duration-timeout-futures","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/scala-infinite-duration-timeout-futures\/","title":{"rendered":"Scala: infinite duration \/ timeout for Futures"},"content":{"rendered":"<p>For whatever reason, a lot of blog posts I&#8217;ve seen put timeouts on Futures, and it took me some time to find the &#8220;infinite&#8221; one. <\/p>\n<p>If you want to do this, here is what you need:<\/p>\n<pre lang=\"scala\">\nimport scala.concurrent.duration.Duration\n\nval tasks = for (thread <- 1 to 10) yield Future {\n  doSomething\n}\n\nval aggr = Future.sequence(tasks)\n\nAwait.result(aggr, Duration.Inf)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For whatever reason, a lot of blog posts I&#8217;ve seen put timeouts on Futures, and it took me some time to find the &#8220;infinite&#8221; one. If you want to do this, here is what you need: import scala.concurrent.duration.Duration val tasks = for (thread<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[480,486],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3546"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3546"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3546\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}