Messaging with Java - Python

We have one program in Java and one in Python, and you need to collect them in the form of a ping-pong, each time exchanging an entire array of 100,000 in length and taking 0.1-1 second to do your job:

  • Java does some work and runs an int array with a length of 100,000 ...
  • Python that does some work and launches a new array with a length of 100,000 ...
  • Java that does some work ... etc.

note that

  • Each program needs to wait until the other makes it part.
  • They will run on the same Linux machine.
  • We will do Monte Carlo simulations, so speed is important.

I am more familiar with Java and understand that a file approach with shared memory support is likely to be the fastest. This seems to be relevant for the Java side, but how can I make each program wait / block so that the other ends its work and updates the shared memory before it starts reading? I heard about something called a semaphore, but I can’t understand.

These are my backup ideas, but maybe they are better?

+4
source share
2 answers

Go for a quick intermediate data server to help in communication between them. Radish would do the trick. You will need two data structures:

  • ( 100 000 ). my_project:list .
  • . Redis, "Python" "Java".

:

  • Python Java Redis. "Python", Python. "Java", Java.
  • , , , , my_project:list, .
  • .
+1

java python , jep. ​​ python java numpy ndarrays java . , .

+1

Source: https://habr.com/ru/post/1675991/


All Articles