Tobias Marschall
10/23/2021, 5:47 PMget("/test") {
launch {
// do something
}
call.respond("Success")
}
Warning Ambiguous coroutineContext due to CoroutineScope receiver of suspend function
when using:
suspend fun PipelineContext<Unit, ApplicationCall>.handleTest() {
launch {
// do something
}
call.respond("Success")
}
get("/test") {
handleTest()
}
How am i supposed to do this?hfhbd
10/23/2021, 10:59 PMsuspend fun handleTest(): String { return "Success"}
or
fun PipelineContext.handleTest() {
call.respond("Success")
}
Tobias Marschall
10/24/2021, 10:24 AMTobias Marschall
10/24/2021, 10:24 AMTobias Marschall
10/24/2021, 11:57 AMdarkmoon_uk
10/24/2021, 1:45 PMTobias Marschall
10/24/2021, 2:47 PMJoost Klitsie
10/24/2021, 6:49 PMlaunch
, you use the pipelines' scope. You should just define another scope (CoroutineScope(Dispatchers.Default)
for example) and this worked like a charm!Tobias Marschall
10/24/2021, 6:51 PMJoost Klitsie
10/24/2021, 6:54 PMTobias Marschall
10/24/2021, 6:56 PMJoost Klitsie
10/24/2021, 6:56 PMTobias Marschall
10/24/2021, 6:56 PMAleksei Tirman [JB]
10/25/2021, 8:21 AMlaunch(coroutineContext + Job()) {
repeat(10000) {
println("Executing background task $it.")
delay(1000)
}
}
Tobias Marschall
10/25/2021, 1:43 PMAleksei Tirman [JB]
10/25/2021, 5:53 PMTobias Marschall
10/25/2021, 7:21 PM+ Job()
. As the jobs will not get cancelled anyways it should not be required, shouldn’t it?hfhbd
10/26/2021, 9:07 AMTobias Marschall
11/01/2021, 5:29 PM