1
私は、計算を実行する関数を含むクラスを持っています。これらのオブジェクトのインスタンスが複数ある場合、どのように計算を並行して行うのですか? Python 2.7で異なるインスタンス化のクラスメソッドを並列に呼び出す方法は?
class SomeClass:
def __init__(self, arg):
....
def compute(self):
....
し、別のスクリプトで
:from multiprocessing import Pool
from wherever import SomeClass
g1 = SomeClass(arg1)
g2 = SomeClass(arg2)
pool = Pool(processes = 2)
にはどうすれば労働者の1がg1.compute()および他のg2.computeを間に合わせますか()?あなたが与えられた引数で計算メソッドを呼び出すワーカー関数を定義する必要がありますpython2.7で
ありがとうございました。 – Chicony