Python 多处理:自定义进程池
我将 Process 类子类化为一个名为 EdgeRenderer 的类。 我想使用 multiprocessing.Pool
,但我希望它们成为 EdgeRenderer 的实例,而不是常规进程。 可能的? 如何?
I am subclassing the Process class, into a class I call EdgeRenderer. I want to use multiprocessing.Pool
, except instead of regular Processes, I want them to be instances of my EdgeRenderer. Possible? How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这似乎有效:
This seems to work:
来自杰西·诺勒:
From Jesse Noller:
我在 API 中没有看到它的任何钩子。 您也许可以使用
initializer
和initargs
参数来复制所需的功能。 或者,您可以将功能构建到用于映射的可调用对象中:I don't see any hook for it in the API. You might be able to get away with replicating your desired functionality by using
initializer
andinitargs
argument. Alternately, you can build the functionality into the callable object that you use for mapping: