Is shared readonly data copied to different processes for multiprocessing?
The piece of code that I have looks some what like this:
The piece of code that I have looks some what like this:
I am not sure whether this counts more as an OS issue, but I thought I would ask here in case anyone has some insight from the Python end of things.
Right now I have a central module in a framework that spawns multiple processes using the Python 2.6 multiprocessing module. Because it uses multiprocessing, there is module-level multiprocessing-aware log, LOG = multiprocessing.get_logger(). Per the docs, this logger has process-shared locks so that you don’t garble things up in sys.stderr (or whatever filehandle) by having multiple processes writing to it simultaneously.
The documentation for the multiprocessing module shows how to pass a queue to a process started with multiprocessing.Process. But how can I share a queue with asynchronous worker processes started with apply_async? I don’t need dynamic joining or anything else, just a way for the workers to (repeatedly) report their results back to base.
How can I handle KeyboardInterrupt events with python’s multiprocessing Pools? Here is a simple example:
Would it be possible to create a python Pool that is non-daemonic? I want a pool to be able to call a function that has another pool inside.
I am attempting to use a partial function so that pool.map() can target a function that has more than one parameter (in this case a Lock() object).
I have a very large (read only) array of data that I want to be processed by multiple processes in parallel.
I am trying to solve a big numerical problem which involves lots of subproblems, and I’m using Python’s multiprocessing module (specifically Pool.map) to split up different independent subproblems onto different cores. Each subproblem involves computing lots of sub-subproblems, and I’m trying to effectively memoize these results by storing them to a file if they have not been computed by any process yet, otherwise skip the computation and just read the results from the file.
I tried to read the documentation at http://docs.python.org/dev/library/multiprocessing.html but I’m still struggling with multiprocessing Queue, Pool and Locking. And for now I was able to build the example below.