Best way to map a generated list to a task in celery

前端 未结 1 1133
再見小時候
再見小時候 2021-01-03 04:43

I am looking for some advice as to the best way to map a list generated from a task to another task in celery.

Let\'s say I have a task called parse, wh

相关标签:
1条回答
  • 2021-01-03 04:59

    This is probably far too late to be of use to you, but you probably want to use a task chain:

    @celery.task
    def process():
        return chain(parse.s(), feed_map.s())
    
    @celery.task
    def feed_map(pages):
        return feed.map(pages)
    

    if you have some final task, say final, you could do this:

    @celery.task
    def feed_map(pages):
        return chord(feed.map.s(page) for page in pages, final.s)
    
    0 讨论(0)
提交回复
热议问题