Closed cypressious closed 7 years ago
I've tried and I see no issue: https://gist.github.com/gildor/aa2b2f23ffbc963e3bde2f180150cc07
Could you reproduce this issue and share code? The only possible reason that I see it's some exceptions in your OkHttp interceptor or Retrofit adapter factory, I just not sure that in this case, coroutine getting callbacks
When I build and run the project in https://gist.github.com/anonymous/e13969100d35b778986db6bf7fb2275f, the app doesn't terminate.
I'm sorry, the gist is a bit messy, you can compile the project from these sources
Yes, I see that if I use gradle application plugin and run
task.
Looks like some thread still alive, even after coroutines finished. I will investigate this
@cypressious Sorry, I had no time to investigate, but just now got the same problem with retofit + rxjava2 call adapter RxJava2CallAdapterFactory.createAsync()
so it's not only coroutine implementation problem. And program will be finished in 1 min, same as for coroutines.
Will investigate.
@cypressious The reason of that behavior Executors.newCachedThreadPool()
that used as default executor for Retrofit2 (except cases when you run request synchronously).
According to [docs](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()) threads of CachedThreadPool wait 60 seconds before shutdown.
So I see only one way: set custom Executor to OkHttpClient and shutdown it manually or create executor that creates daemon threads.
@cypressious I'm closing this issue. if you have some other ideas please reopen with your comment
This program doesn't terminate