scaerospike
scaerospike copied to clipboard
Await.result does not block example
I am trying the following example and the Await.result does not seem to be blocking at all. Is this intended?
val read : Future[Option[String]] = devices.get("deviceA")
read.onComplete { case Failure(ex) => ex.printStackTrace() case Success(value) => println("Successfully read " + value) }
Await.result(read, 10 seconds)
I've not this problem but something more weird In my case the future on the read never complete Why this
This is the code val write : Future[Unit] = set.put("2", cacheData) val read : Future[Option[CacheData]] = set.get("2") val future = write flatMap(_ => read)
future onComplete { case Success(data) => println("Get Object" + data.getOrElse("empty")) case Failure(ex) => ex.printStackTrace() }
Thread.sleep(10000)