Skip to content

Also interrupt pollers when shutting down the WSTP#4340

Merged
djspiewak merged 4 commits intotypelevel:series/3.6.xfrom
durban:fixWstpShutdownInterrupt
Apr 3, 2025
Merged

Also interrupt pollers when shutting down the WSTP#4340
djspiewak merged 4 commits intotypelevel:series/3.6.xfrom
durban:fixWstpShutdownInterrupt

Conversation

@durban
Copy link
Copy Markdown
Contributor

@durban durban commented Apr 3, 2025

As discussed in #4201.

Copy link
Copy Markdown
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Thanks! Want to add a test? 🤠

@durban
Copy link
Copy Markdown
Contributor Author

durban commented Apr 3, 2025

I was thinking about a test... but this is only JVM (in this branch), and on the JVM it already works correctly. So what would we test?

@armanbilge
Copy link
Copy Markdown
Member

and on the JVM it already works correctly

It doesn't work correctly on the JVM, it just so happens that our current polling systems happen to respect Thread#interrupt. But a different polling system (such as the io_uring one) would not work correctly. It should be possible to construct a polling system for the test that doesn't respect Thread#interrupt e.g. by swallowing the exception and looping.

@djspiewak
Copy link
Copy Markdown
Member

I think the best way to test this is probably to make a mock polling system that just mutates a flag when it gets interrupted. Then make a runtime, wait a second, and shut it down.

@durban
Copy link
Copy Markdown
Contributor Author

durban commented Apr 3, 2025

Yeah, uh... we could do that. But I was already almost done with this much more convoluted test, when you wrote that comment... :-) This way at least we're testing a somewhat realistic shutdown procedure, if I didn't mess it up. (But let me know it it's too much.)

Copy link
Copy Markdown
Member

@djspiewak djspiewak left a comment

Choose a reason for hiding this comment

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

LOL! I mean, this is magnificent, but I think it'll be easier to maintain if we do the mock interrupt thing. We can even make it deterministic because we can release a latch when we "sleep", which then would trigger the test to shutdown the runtime. Or we could even shut down the runtime directly from inside the mock system, that type of thing.

Copy link
Copy Markdown
Member

@djspiewak djspiewak left a comment

Choose a reason for hiding this comment

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

Excellent!

@djspiewak djspiewak merged commit fc72e9b into typelevel:series/3.6.x Apr 3, 2025
34 of 36 checks passed
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.

3 participants