为什么平行的Python可以按照自己的方式工作?
-
28-09-2019 - |
题
在平行的Python中,为什么有必要包装任何模块,该函数将需要以及该作业提交呼叫中的变量和名称空间 - 保留模块级别“全局”变量的必要性? (如果这是所有正在进行的)
提交功能:
submit(self, func, args=(), depfuncs=(), modules=(), callback=None, callbackargs=(),group='default', globals=None)
Submits function to the execution queue
func - function to be executed
args - tuple with arguments of the 'func'
depfuncs - tuple with functions which might be called from 'func'
modules - tuple with module names to import
callback - callback function which will be called with argument
list equal to callbackargs+(result,)
as soon as calculation is done
callbackargs - additional arguments for callback function
group - job group, is used when wait(group) is called to wait for
jobs in a given group to finish
globals - dictionary from which all modules, functions and classes
will be imported, for instance: globals=globals()
解决方案
原因 pp
按照自己的方式工作,它为每个工人制作了Python解释器的新实例,这完全独立于之前或之后运行的任何事物。这样可以确保没有意想不到的副作用,例如 __future__
进口在工作过程中活跃。问题在于,它使事情变得更加复杂,并且在我的经验中 pp
, ,不是特别强大。 pp
做 尝试使用户更容易一些事情,但似乎引入了比其在做到这一点的努力中解决的更多问题。
如果我从一开始就编写用于在集群上使用的代码,我可能最终会使用 pp
, ,但是我发现适应现有代码来使用 pp
是一场噩梦。
不隶属于 StackOverflow