更改 Python 多处理管理器的派生进程名称
Change the spawned process name for Python multiprocessing manager
我想使用 setproctitle 更改生成的多处理管理器 SyncManager 的进程名称,我尝试扩展 multiprocessing.managers.SyncManager:
class MySyncManager(multiprocessing.managers.SyncManager):
def __init__(self):
super(MySyncManager, self).__init__()
self.daemon=True
def run(self):
setproctitle.setproctitle('MySyncManager')
super(MySyncManager, self).run()
if __name__ == '__main__':
mySyncManager = MySyncManager()
mySyncManager.start()
但是好像不行。知道怎么做吗?
我找到了问题的答案。
def changeProcessTitle(title):
from setproctitle import setproctitle
setproctitle(title)
class MySyncManager(multiprocessing.managers.SyncManager):
def __init__(self):
super(MySyncManager, self).__init__()
self.daemon=True
if __name__ == '__main__':
mySyncManager = MySyncManager()
initArgs = ('MySyncManager', )
mySyncManager.start(changeProcessTitle, initArgs)
我想使用 setproctitle 更改生成的多处理管理器 SyncManager 的进程名称,我尝试扩展 multiprocessing.managers.SyncManager:
class MySyncManager(multiprocessing.managers.SyncManager):
def __init__(self):
super(MySyncManager, self).__init__()
self.daemon=True
def run(self):
setproctitle.setproctitle('MySyncManager')
super(MySyncManager, self).run()
if __name__ == '__main__':
mySyncManager = MySyncManager()
mySyncManager.start()
但是好像不行。知道怎么做吗?
我找到了问题的答案。
def changeProcessTitle(title):
from setproctitle import setproctitle
setproctitle(title)
class MySyncManager(multiprocessing.managers.SyncManager):
def __init__(self):
super(MySyncManager, self).__init__()
self.daemon=True
if __name__ == '__main__':
mySyncManager = MySyncManager()
initArgs = ('MySyncManager', )
mySyncManager.start(changeProcessTitle, initArgs)