Return from mp.spawn()

Is there a better way to return values from spawned functions?

If you want to pass the result from spawned processes back to the parent process, you can let the parent process create multiprocessing queues, pass it to children processes, and let children processes send result back through the queue. See the following code:

If the result does not have to go back to the parent process, you can use gather or allgather to communicate the result across children processes.

4 Likes