我曾經有過這樣的芹菜和信號
def calculate(self, input):
result = input * 2
if result > 4:
result_higher_then_four.send(result)
return result
其中result_higher_then_four
顯然代表了信號的功能。
然後我介紹芹菜和我的功能看起來像下面,我再也沒有收到信號。我想信號是按每個進程綁定的,因爲芹菜在不同的進程中運行,這意味着我無法在主進程中捕捉到信號。我應該使用thread_local
來解決這個問題嗎?還是我忽略了顯而易見的?
感謝
@task
def calculate(self, input):
result = input * 2
if result > 4:
result_higher_then_four.send(result)
return result
@ChillarAnand是 – user2298943 2014-09-07 11:13:26