Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect sbt thread cleaner and terminate workers #2705

Merged
merged 4 commits into from
Dec 31, 2021

Conversation

djspiewak
Copy link
Member

Also added a non-fatal test which doesn't reproduce the issue. I wasn't able to come up with a good way of rigorously testing this.

Fixes #2704

@armanbilge
Copy link
Member

It's super annoying, but you have to register the new example app here for JS:

object JSRunner {
val apps = mutable.Map.empty[String, IOApp]
def register(app: IOApp): Unit = apps(app.getClass.getName.init) = app
register(HelloWorld)
register(Arguments)
register(FatalError)
register(Canceled)
register(GlobalRacingInit)
register(ShutdownHookImmediateTimeout)
register(LiveFiberSnapshot)
register(FatalErrorUnsafeRun)
register(Finalizers)

cont = parked.get()
// the only way we can be interrupted here is if it happened *externally* (probably sbt)
if (isInterrupted())
done.set(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clashes with the shutdown() method on WorkStealingThreadPool. I wonder if that method should be called instead, there's already a CAS which will make sure to call it once. Only setting done won't clean up all resources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with all this is that I don't know if the rest of the thread pools in the same IORuntime are shut down. Technically, IORuntime#shutdown() can also be called, since the WSTP has a reference to its IORuntime.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can swap it to call shutdown(). I'm actually not as worried about the other pools in the runtime because this is such an odd scenario. It'a kind of like being shut down from the inside out, and we can assume it's happening to everyone and not just us.

Copy link
Member

@vasilmkd vasilmkd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on.

@djspiewak djspiewak merged commit bee01f5 into typelevel:series/3.3.x Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants