All Questions
1,199
questions
1
vote
1
answer
48
views
Scala Future strange behavior
What's wrong with this code? Why I can see only one output? What returns futureUserByName function? onComplete doesn't work for it as well. It must be just simple Future, but it doesn't work.
import ...
1
vote
1
answer
129
views
List of Future is not executed in parallel
I don't understand why this code is not executed in parallel.
implicit val ec: ExecutionContext = system.dispatchers.lookup("db-non-blocking")
println(s"Cores ${Runtime.getRuntime()....
0
votes
0
answers
18
views
Multiple streamed response combined in a single iterator in Scala
I have multiple replicas of a service from which I am receiving a stream of response:
// RPC call to server that returns a stream of response.
def getResult(input: Request): Iterator[ResultItem]
On ...
1
vote
1
answer
47
views
Scala wait Await.result for Future.sequence, which futures did not complete on time?
I have list of futures and Await
val listWithResult = Await.result(Future.sequence(listOfFutures), 10.minutes)
It fails with
java.util.concurrent.TimeoutException: Futures timed out after [10 minutes]...
0
votes
2
answers
72
views
Scala for comprehension responding Future.filter predicate is not satisfied
I got the followin code
val obj1Seq: Future[Seq[Object1]] = /* call function returning Future[Seq[Object1]] */
val obj2Seq: Future[Seq[Object2]] = /* call function returning Future[Seq[Object2]] */
...
0
votes
1
answer
72
views
Map value from a Future to Object and not Future[Object]
I have a function that return a Future[State] and another function that I need return a StateSimplified object
//class State
case class State(id: String, label: String, postalCode: String, extension: ...
0
votes
0
answers
61
views
List[Future[A]] => Future[(List[A], List[Throwable])] the most correct solution
I have solution:
def foo[A](futures: List[Future[A]])(implicit ec: ExecutionContext): Future[(List[A], List[Throwable])] =
futures.foldLeft(Future.successful(List.empty[A] -> List.empty[Throwable]...
1
vote
1
answer
152
views
Converting monix.eval.Task to scala.concurrent.Future
I’m trying to reuse some module that uses monix.eval.Task for async tasks.
My project uses scala.concurrent.Future.
I'm trying to understand the best way to convert it to Future with the least amount ...
-2
votes
1
answer
44
views
Wrapping futures with custom objects [closed]
Is it possible in scala to add custom variables while creating futures (like some kind of context) that stick with the future task and is available throughout the task since futures are immutable once ...
0
votes
1
answer
69
views
Based on api response call another api - nested api in Scala
I am not an expert in Scala and this might be trivial scenario, tried a lot but it doesn't seem to work.
Basically based on a condition I need to call an api and based on the response of the api I ...
0
votes
1
answer
41
views
Scalatra asyncPost multiple unit tests mixed up requests
I'm new to scala so I might not be clear with the issue I'm facing, I might not be including all the details needed to identify the issue. I'll do my best to clarify.
I'm converting a post scalatra ...
0
votes
0
answers
73
views
Why `final` required in this Future-style concurrent programming in Scala?
I have a question about the use of the final related with Fiture-style concurrent programming. Thank you for your time.
I have a simple Future-style concurrent program, which spawns many Futures, ...
2
votes
0
answers
111
views
Can I mixed use Scala ExecutionContext and Java ExecutorSerivce
I noticed that scala ExecutionContext has a def fromExecutorService(e: ExecutorService) which convert a Java ExecutorService to scala ExecutionContext.
Can I mixed use these two? i.e.,:
val ...
0
votes
1
answer
81
views
Scala: can't get the Future result
I'm trying to run a simple Future example in Intellij Idea:
import scala.concurrent.ExecutionContext.Implicits.global
object Futures1 extends App {
val f = Future {
Thread....
0
votes
1
answer
238
views
Scala: Prevent race condition when performing some action after one Future fails out of a sequence of futures
I have a mutable list of futures: ArrayBuffer[Future[Seq[T]]]
While my program is running, new Futures are added to that list over time, and complete on their own eventually. After each Future ...