-
Notifications
You must be signed in to change notification settings - Fork 181
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
Question - it's possible to use jpype with multiprocessing #533
Comments
Pickle support was added to the repo a bit ago (#481), but I can’t say how well that will work with the multiprocessing in Python. Some of the tests in the jpypetest directory use primitive types to spawn a job and start a jvm in the remote process, so at least I know that jpype will work in a multiprocess context. Unfortunately, this hasn’t had a lot of focus or testing. So first I would recommend getting the jpype version with pickle support, try your tests again, then if it doesn’t work look over the jpypetest to see how we got multiprocessing working. I believe the leak tester and the startJVM tests both use some sort of multiprocessing.
|
Ok, I'm trying to build newer release from source but now I've new questions :)
In any case now I've jpype.pickle working but multiprocessing is not able to serialize the class like before.. I need to specify something? Thanks |
Master should be the correct branch. And it should not have any fails.
Please submit a log with failed tests.
|
I've update the log in this gist: https://gist.github.com/dadokkio/608a6322f2b0fa7054bca83e11ada195 [root@xxx1 jpype-master]# echo $JAVA_HOME [root@xxx1 jpype-master]# python --version [root@xxx1 jpype-master]# cat /etc/redhat-release |
A portion of your test harness is not being built thus it can’t find the java portion of the test.
I recommend manually rebuilding the test harness and rerunning the tests. I was not able to replicate your exact symptoms with a clean build.
Here is an example of a manual build of the harness
```
$ ant -f test/build.xml
Buildfile: C:\Users\nelson85\cygwin\devel\open\test\jpype\test\build.xml
compile-main:
[javac] C:\Users\nelson85\cygwin\devel\open\test\jpype\test\build.xml:52: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 1 source file to C:\Users\nelson85\cygwin\devel\open\test\jpype\test\classes
compile-8:
[javac] C:\Users\nelson85\cygwin\devel\open\test\jpype\test\build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
compile-9:
[javac] C:\Users\nelson85\cygwin\devel\open\test\jpype\test\build.xml:25: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
compile:
test:
BUILD SUCCESSFUL
Total time: 0 seconds
```
Beyond this issue it all looks fine. All of the tests that failed seem likely to pass if the harness is in place as they all are dummy checks to make sure we haven’t broken things on a patch, and all pass on a similarly configured machine.
|
Ok, that's worked! But I've the same situation than before:
Do I need to specify the pickling class somewhere? |
The pickler documentation is specified in jpype/pickle.py. When pickling we must create a custom pickler with the java hooks for calling the java serializer. I am not sure how you would pass the custom pickler to the multiclass, but assuming you can then it should all work.
|
Ok, I was able to use the class with getstate and setstate but my problem seems to be related to the class itself because it returns: |
All classes that are intended to be serialized need java.lang.Serializable as their base. Unfortunately if this is not true there isn’t a way to push them through that I am aware of.
|
Hi,
I'm trying to parallelize some jpype code using multiprocessing but I'm not sure if this is possible and if this is the correct way to proceed.
In this way multiprocessing is not able to pickle the class so I tried to initialize the class directly in the write_data function:
With this second method I can see all processes spawned but then nothing happens.
Any help?
The text was updated successfully, but these errors were encountered: