scaerospike icon indicating copy to clipboard operation
scaerospike copied to clipboard

Await.result does not block example

Open phufool opened this issue 10 years ago • 1 comments

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)

phufool avatar Jan 13 '15 03:01 phufool

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)

richiesgr avatar Feb 25 '15 13:02 richiesgr