Support clean shutdown of TaskRunner threads and documentation
See original GitHub issueHello,
I am precisely in a situation where I need to shutdown a client manually.
We are developing an IntelliJ plugins that uses OkHttp (https://sonarlint.org/). Since latest versions of IntelliJ, plugins can be installed and uninstalled without restarting the IDE. It means that when plugin is uninstalled we need to unload all the classes we use, and OkHttp is part of that.
I followed the guidelines here: https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#shutdown-isnt-necessary, and I use the latest version (4.7.2).
It appears that the steps described in this page are not sufficient. I can still see an instance of TaskRunner and RealBackend, that retains an ThreadPoolExecutor. I had to call also:
((TaskRunner.RealBackend)TaskRunner.INSTANCE.getBackend()).shutdown();
Which is a bit hacky, but this correctly released the executor.
I think this should be at least documented, or maybe improved with a better API. The shutdown
method could possibly be defined in the Backend
interface.
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (7 by maintainers)
Top GitHub Comments
No worries! Yeah reusing the same process, afaik, just allocating a Thread to the Isolate for the code that runs in its context.
The Okio watchdog is an process-wide singleton and there’s no place to configure it.