If you are ready to install an open source package, you should consider Ray , which of the Python frameworks is probably the closest option to single-threaded Python. This allows you to parallelize both functions (as tasks) and classes with state (as actors), and automatically performs all delivery and serialization of data, as well as the distribution of exception messages. It also provides flexibility similar to regular Python (actors can be transferred, tasks can cause other tasks, there may be arbitrary data dependencies, etc.). Read more about this in the documentation .
As an example, here is how you would make your example of a multiprocessor card in Ray:
import ray ray.init() @ray.remote def mapping_function(input): return input + 1 results = ray.get([mapping_function.remote(i) for i in range(100)])
The API is slightly different from the multiprocessor Python API, but should be easier to use.
You can install Ray using "pip install ray" and then run the above code on one node, or it is also easy to configure a cluster, see Cloud Support and Cluster Support.
Disclaimer: I am one of the developers of Ray.
Philipp Moritz Feb 06 '19 at 22:30 2019-02-06 22:30
source share