I developing console application on Kotlin. If I make a request from the main thread and request finishes (successful or not, doesn't matter) application won't close for a minute. Is that normal behavior? Is there a way to stop execution right after result handler finishes its execution?
Request:
Fuel.get("/info").responseString { _, _, result ->
when (result) {
is Result.Failure -> {
println("Failure")
}
is Result.Success -> {
println("Success")
}
}
}
Just noticed the same problem. I'm guessing it's a problem with the jvm waiting for the async thread to officially close, because if you use the non-async version it terminates immediately.
Fuel opens a daemon thread that prevents the JVM from shutdown.
You can try this code to shutdown Fuel, though it should probably provide a better masochism for that:
FuelManager.executor.shutdownNow()
Is someone familiar with how OKHttp handles that?
Same as #99
can we close this?
Yes, @yoavst solution works. Thank you!