ESchouten
06/27/2024, 11:32 AMflow {
while(true){
delay(interval)
emit(true)
}
}.onEach {
try {
//poll here
} catch (t: Throwable) {
logger.error(t.message ?: "")
}
logger.debug("Poller run finished")
}.launchIn(application)
Now this can run for weeks without problems, and then all of a sudden the poller stops.
I am totally lost as to why that could happen. Does anyone have a clue?ross_a
06/27/2024, 11:34 AMapplication
scope? Does it have a supervisor job, have you attached an exception handler to it etcross_a
06/27/2024, 11:35 AMESchouten
06/27/2024, 11:45 AMross_a
06/27/2024, 11:54 AMross_a
06/27/2024, 11:57 AMpoll
ever not return?
You could use this to cancel an outstanding poll request if it doesn't return before the next interval fires
application.launch {
flow {
while(true){
delay(interval)
emit(true)
}
}.collectLatest {
try {
//poll here
} catch (t: Throwable) {
logger.error(t.message ?: "")
}
logger.debug("Poller run finished")
}
}
ross_a
06/27/2024, 11:57 AMross_a
06/27/2024, 12:02 PMross_a
06/27/2024, 12:02 PMESchouten
06/27/2024, 12:19 PMwithTimeout
until I saw your elegant solution. Thanks a lot, pretty positive this fixed it.