The Python Language: Multi-Processing

#Python #Programming Language #Basics

Python has built-in multiprocessing module in its standard library.

One simple example of using the Pool class is the following.

def myfunc(myfuncargs):
    'some thing here'

with Pool(10) as p:
    records =, myfuncargs)

However, there are limitations on this, especially on pickles. Another approach.

from multiprocessing import Pool
from multiprocessing.dummy import Pool as ThreadPool

with ThreadPool(1) as p:
    records =, myfuncargs)

Beware that map function will feed in a list of args to the function. So I have to use, [arg]) for one arg.

Published: by ;

Lei Ma (2018). 'The Python Language: Multi-Processing', Datumorphism, 05 April. Available at:

Table of Contents

Current Ref:

  • wiki/programming-languages/python/