-
Notifications
You must be signed in to change notification settings - Fork 217
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
Multithreaded python calls to java return deranged results #523
Comments
Does it use multiprocessing from gunicorn? Py4J is thread-safe but doesn't work well with multiprocessing. |
When will this problem be solved? |
If this is from multiprocessing, it would not be fixed because Py4J does not support multiprocessing by design. |
I tried using gunicorn to start a work to start a python method, that is, a single process, and then the python method used multiple threads to call java, but it still returned confusing results. Am I doing it wrong? |
Would be great if there's a reproducer without gunicorn to investigate this further. My guts say gurnicorn uses a separate process when you use Py4J. |
Background: Start with the java code and use gunicorn to start the python server with multiple works
The java side uses the following code:
public static void main(String[] args) {
GatewayServer server = new GatewayServer(func);
server.start();
The python side uses the following code:
from py4j.java_gateway import JavaGateway
jvm = JavaGateway()
function = jvm.getfunc()
When multiple threads from python call java, the result will be confused. For example, the input of thread 1 is not returned to thread 1, but to thread 2
The text was updated successfully, but these errors were encountered: