Process communication of Python's Multiprocessing

一世执手 提交于 2019-12-03 07:05:16

Your question is quite broad and most of the answers can be found in the multiprocessing module documentation.

Here follows a somewhat short answer.

  1. The multiprocessing Listeners and Clients allow to choose named pipes as transport medium.
  2. From the documentation:

    The multiprocessing.sharedctypes module provides functions for allocating ctypes objects from shared memory which can be inherited by child processes.

    You cannot use multiprocessing.sharedctypes functionalities across processes which don't have parent/child relationship.

  3. Managers and Listeners and Clients work across processes on different hosts or which do not have parent/child relationship. The AF_INET socket family can be used across different hosts. Nevertheless I'd recommend against it. Rather use network sockets or some other abstraction mechanism.
  4. Differences and characteristics are well illustrated in the documentation.

Python multiprocessing module was initially implemented over the threading APIs. By the time, it grew in features it supports but the core idea remains the same. The multiprocessing module is intended to deal with Python process families. For any other use, the subprocess module is a better option.

For distribution of tasks and jobs across multiple hosts, there are far better solutions abstracting the low level infrastructure. You can take a look at Python projects such as Celery or Luigi or more complex infrastructures such as Apache Mesos.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!