[issue24519] multiprocessing.Pool with maxtasksperchild starts too many processes

Zahari Dim report at bugs.python.org
Sat Jun 27 11:22:06 CEST 2015


New submission from Zahari Dim:

The following example should start two processes, but instead it starts three, even though only two do_work(). A third process is incorrectly started after the first one finishes.

import os
import time
from multiprocessing import Pool

def initprocess():
    print("Starting PID: %d" % os.getpid())

def do_work(x):
    print("Doing work in %d" % os.getpid())
    time.sleep(x**2)

if __name__ == '__main__':
    p = Pool(2, initializer=initprocess,maxtasksperchild=1)
    results = p.map(do_work, (1,2), chunksize=1)

----------
components: Library (Lib)
messages: 245878
nosy: Zahari.Dim
priority: normal
severity: normal
status: open
title: multiprocessing.Pool with maxtasksperchild starts too many processes
type: resource usage
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24519>
_______________________________________


More information about the Python-bugs-list mailing list