所以開始我從來沒有平行處理任何東西......所以我不知道我在做什麼,但是我已經讀了一下,我已經仍然有一個問題。我的問題似乎是最喜歡這篇文章在這裏How to do parallel programming in Python 我有需要一段時間,並能獨立工作多處理池-error從不成功的返回字典得到
# set dates to get data
d1 = DT.datetime(2015, 10, 1)
d2 = DT.datetime(2015, 10, 2)
# sets up a class to get various types of data from various places
gd = getdata(d1, d2)
# both below return dictionary with unprocessed data
rawspec = gd.getwavespec(gaugenumber=0)
rawwind = gd.getwind(gaugenumber=0)
目前,各功能獨立運行,並返回,大約需要每1-5分鐘,在它的數據字典兩種功能。 (例如rawwind = {風速,方向,時間},rawspec = {時間,Hs,Tp,Tm,1D光譜,2D光譜等})我想並行運行以加快數據準備工作流程。當我使用上面的鏈接作爲一個框架的工作和嘗試以下方法,我得到一個錯誤,一個TypeError: 'dict' object is not callable
from multiprocessing import Pool
pool = Pool()
result = pool.apply_async(gd.getwavespec(), ['gaugenumber=0'])
# here i get print statements that suggest the data are retrieved
Data Gathered From Local Thredds Server
result.get(timeout=1000)
Traceback (most recent call last):
File "/home/spike/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-115-19dc220c614d>", line 1, in <module>
result.get(timeout=100)
File "/home/spike/anaconda2/lib/python2.7/multiprocessing/pool.py", line 567, in get
raise self._value
TypeError: 'dict' object is not callable
當我檢查,如果調用成功與result.successful()
我得到一個False
回來,我真的不知道如何解決這個問題,當我從ipython控制檯運行rawspec = gd.getwavespec(gaugenumber=0)
我成功返回,任何幫助非常感謝