Celery和弦上的Gene Expression错误?

时间:2014-06-26 09:23:31

标签: python celery

我写了一个像这样的芹菜弦:

current = raw_input("Please give the date in this format 'dd/mm/yyyy': ")
day,month,year = current.split('/')
date = datetime.date(int(year), int(month), int(day))
date1 = datetime.date(2014, 06, 17)
date = date.toordinal()
date1 = date1.toordinal()

callback = A.si((datetime.date.fromordinal(i)) for i in range(date,date1+1))
header = [B.si((datetime.date.fromordinal(i)) for i in range(date,date1+1))]
result = chord(header)(callback)
res = result.apply_async()
res.get()

现在我遇到了这个错误:

TypeError: object.__new__(generator) is not safe, use generator.__new__()

我怎么能写callbackheader ?????

1 个答案:

答案 0 :(得分:0)

我怀疑它正在发生,因为Celery正在进行一些序列化(默认使用pickle,取决于你的版本)/任务参数的副本,以及生成器cannot be pickled或{{3} },它会产生这个错误。你应该尝试使用列表(或元组):

dates = [datetime.date.fromordinal(i) for i in range(date, date1 + 1)]
callback = A.si(dates)
header = [B.si(dates)]
result = chord(header)(callback)
res = result.apply_async()
res.get()