Why do these Python server processes accumulate?

放肆的年华 提交于 2019-12-13 06:58:46

问题


Ignoring the actual utility, I have the following classes:

from multiprocessing import Manager
import threading


class MgrStaticTarget(object):

    def __init__(self):
        self._mgr = Manager()
        self._thd = threading.Thread(target=self.async_targ)

    @staticmethod
    def async_targ():
        pass

class MgrInstanceTarget(object):

    def __init__(self):
        self._mgr = Manager()
        self._thd = threading.Thread(target=self.async_targ)

    def async_targ(self):
        pass

and I'm observing behavior I don't understand. Upon repeated instantiations of MgrInstanceTarget using a Python shell in the following manner:

i = MgrInstanceTarget()
i = MgrInstanceTarget()
i = MgrInstanceTarget()
i = MgrInstanceTarget()

the multiprocessing.Manager server processes (or at least that's what I believe they are from) are accumulating.

However, if I instantiate MgrStaticTarget in the same manner the server processes do not accumulate. The only processes that exist are the one for the most recent Manager server process and the python shell. What's going on here?

来源:https://stackoverflow.com/questions/27933500/why-do-these-python-server-processes-accumulate

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