D
D
devalone2017-03-22 23:27:54
Django
devalone, 2017-03-22 23:27:54

Celery and django. How to make tasks "synchronous"?

There is a jang website that needs to parse the price, I did it on celery, created two tasks, one for parsing the price itself (relatively fast) and the second for downloading pictures (long, because the pictures are in a large archive). Is it now possible to do without special crutches so that tasks of the same type are performed in turn, i.e. if you uploaded 2 price lists, did he parse the first one first, and then the second one?
I start the task from the save method of the model that stores the tasks.parseXml.delay(path_to_file) file, maybe not the best way, but it works :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad, 2017-03-23
@d1skort

docs.celeryproject.org/en/latest/userguide/canvas.html

S
Serhiy Romanov, 2017-04-11
@SerhiyRomanov

Is it now possible to do without special crutches so that tasks of the same type are performed in turn, i.e. if you uploaded 2 price lists, did he parse the first one first, and then the second one?

Put jobs in the same queue
@celery_app.task(
queue="price_queue"
)
def do_parsing():
...

And run the worker itself like this:
But what's the point in this ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question