简体   繁体   中英

What is the best way to get URl of generated file within Celery task

I got a task to make exports of several big tables in DB asynchronous because right now the amount of records is so big that it takes too much time. So I've successfully moved the code of exporting to the Celery task. It exports and saves the file in a folder on a server. But I am not able to get from the task the whole filename, which I could pass to the rest of code and therefore download it after completing the export process because the only thing Celery task can return is only the state of the result of performing the task (done or not yet or failed). I am using Django/Python + Celery + Redis. Thank you for any advice, it already borders me for several days.

After helping comment from Danila, I have tried celery.result library, which I didnt know anything about before (surprisingly I also havent found any mention of it before). After importing ResultBase from celery.result, which captures the incoming results from task, I was finally able to get the URL of my generated file and therefore I got what I needed. Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM