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

Give py4j threads explicit names, mark them as daemon #498

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexarchambault
Copy link

This PR makes py4j give more explicit names to the threads it creates (like py4j-… rather than the default Thread-…), which makes it easier to inspect JVM processes where py4j is running.

It also marks those threads as daemon, so that exiting the main thread of the JVM, by reaching the end of the main method, actually makes the JVM exit (provided no other non-daemon threads were created by users).

@alexarchambault alexarchambault changed the title Give py4j thread an explicit name, mark them as daemon Give py4j threads explicit names, mark them as daemon Aug 24, 2022
@alexarchambault
Copy link
Author

I didn't go as far as allowing py4j users to provide their own ThreadFactory, but I guess that would be the next step. That would allow users to more finely manage py4j threads if they need to.

@HyukjinKwon
Copy link
Member

oh yeah, probably it's a good idea to name them

@@ -0,0 +1,31 @@
package py4j;
Copy link
Member

Choose a reason for hiding this comment

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

I think you don't have to bother with creating a util here. Let's just fix them inplace at GatewayServer, ClientServerConnection, and let's name them.

int index = counter.incrementAndGet();
String name = "py4j-" + index;
Thread thread = new Thread(r, name);
thread.setDaemon(true);
Copy link
Member

Choose a reason for hiding this comment

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

but why should we make it a daemon though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants