我的場景如下:我有一個大型機器學習模型,它由一羣工人計算。實質上,工人計算他們自己的模型部分,然後與結果進行交換,以保持全局一致的模型狀態。如何避免酸洗芹菜任務?
因此,每個芹菜任務計算它是自己的一份工作。 但是這意味着,任務不是無狀態的,這裏是我的麻煩:如果我說some_task.delay(123, 456)
,實際上我是不是在這裏發送兩個整數!
我發送整個任務的狀態,這是在芹菜某處醃製的。這種狀態通常是約200 MB: - ((
我知道,這是可能的選擇芹菜像樣的串行器,但我的問題是如何不鹹菜只是任何數據,這可能是在任務 。 ?如何鹹菜任務的參數只有 這裏是芹菜/應用/ task.py引文:
def __reduce__(self):
# - tasks are pickled into the name of the task only, and the reciever
# - simply grabs it from the local registry.
# - in later versions the module of the task is also included,
# - and the receiving side tries to import that module so that
# - it will work even if the task has not been registered.
mod = type(self).__module__
mod = mod if mod and mod in sys.modules else None
return (_unpickle_task_v2, (self.name, mod), None)
我只是不希望這種事情發生 有它周圍的一個簡單的方法,或者我只是被迫建立我自己的芹菜(這是難以想象的)?
謝謝,裏卡多,但實際上需要使用AsyncResult。這是整個方案的關鍵點。也許可以將任務狀態分成假的「可存儲」部分(只是爲了使AsyncResult工作)和任務的「可用」狀態,而不是每個請求的醃製狀態?我的請求量非常高,每個請求移動200Mbs是不可能的。 –