This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sbt
Recipients mythsmith, sbt
Date 2014-02-18.20:31:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1392755512.18.0.499337240512.issue20660@psf.upfronthosting.co.za>
In-reply-to
Content
On Unix, using the fork start method (which was the only option till 3.4), every sub process will incref every shared object for which its parent has a reference.

This is deliberate because there is not really any way to know which shared objects a subprocess might use.  (On Windows where only things pickled as part of the process object are inherited by the child process, we can know exactly which shared objects the child process should incref.)

Typical programs will only have a single manager (or a very small number) but may have a large number of normal processes (which will also do the increfing).  I do not think that this is worth trying to fix, particularly as it can cause compatibility problems.

For 3.4 you can use the "spawn" or "forkserver" start methods instead.

import multiprocessing, logging

objs = []

def newman(n=50):
    m = multiprocessing.Manager()
    print('created')
    for i in range(n):
        objs.append(m.Value('i',i))
    return m

def foo():
    pass

if __name__ == '__main__':
    ## Try uncommenting next line with Python 3.4
    # multiprocessing.set_start_method('spawn')
    multiprocessing.log_to_stderr(logging.DEBUG)
    print('#### first man')
    m1 = newman()
    print('#### starting foo')
    p = multiprocessing.Process(target=foo)
    p.start()
    p.join()
History
Date User Action Args
2014-02-18 20:31:52sbtsetrecipients: + sbt, mythsmith
2014-02-18 20:31:52sbtsetmessageid: <1392755512.18.0.499337240512.issue20660@psf.upfronthosting.co.za>
2014-02-18 20:31:52sbtlinkissue20660 messages
2014-02-18 20:31:51sbtcreate