Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Await.result does not block example #9

Open
phufool opened this issue Jan 13, 2015 · 1 comment
Open

Await.result does not block example #9

phufool opened this issue Jan 13, 2015 · 1 comment

Comments

@phufool
Copy link

phufool commented Jan 13, 2015

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)

@richiesgr
Copy link

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants