question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support clean shutdown of TaskRunner threads and documentation

See original GitHub issue

Hello,

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:open
  • Created 3 years ago
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfrickertcommented, Jun 9, 2021

No worries! Yeah reusing the same process, afaik, just allocating a Thread to the Isolate for the code that runs in its context.

1reaction
swankjessecommented, Jul 20, 2020

The Okio watchdog is an process-wide singleton and there’s no place to configure it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Re: observing TaskRunner destruction - Google Groups
To be specific: FilePathWatcher (both on Linux and Windows) relies on MessageLoop::DestructionObserver to clean up IO-thread state when the IO thread disappears ...
Read more >
OkHttpClient - OkHttp - Square Open Source
This is because each client holds its own connection pool and thread pools. ... Shutdown the dispatcher's executor service with shutdown().
Read more >
Graceful shutdown of ThreadPoolExecutor when Enclosing ...
As the documentation for Executors.newFixedThreadPool says: The threads in the pool will exist until it is explicitly shutdown .
Read more >
chromiumembedded / cef / wiki / GeneralUsage - Bitbucket
TID_IO thread is used in the browser process to handle IPC and network ... To support synchronized access to blocks of code CEF...
Read more >
Executing Work on Existing Resources Using Task Runner
Task Runner can be installed anywhere, on any compatible hardware or operating system, provided that it can communicate with the AWS Data Pipeline...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found