How do I name the processes in a multiprocessing.pool?

如果我创建一个包含4个worker的池并将它们设置为执行一些任务(使用pool.apply_async(..) ),那么我可以使用multiprocessing.current_process().name从内部访问每个进程的multiprocessing.current_process().name ,但是如何设置来自父进程的名称(这主要是用于日志记录)?


Process.name is just a setter, you can freely assign to it.

The Pool takes an initializer argument. This can be any callable, and it'll be called once when each subprocess starts up. You can point this to a function that sets the name property of that process to whatever you want.

链接地址: http://www.djcxy.com/p/82444.html

上一篇: Mongoose不会创建TTL索引

下一篇: 我如何命名multiprocessing.pool中的进程?