multiprocess or threading in python?

后端 未结 8 1850
我在风中等你
我在风中等你 2020-12-01 02:31

I have a python application that grabs a collection of data and for each piece of data in that collection it performs a task. The task takes some time to complete as there i

8条回答
  •  庸人自扰
    2020-12-01 02:39

    For small collections of data, simply create subprocesses with subprocess.Popen.

    Each subprocess can simply get it's piece of data from stdin or from command-line arguments, do it's processing, and simply write the result to an output file.

    When the subprocesses have all finished (or timed out), you simply merge the output files.

    Very simple.

提交回复
热议问题