Home > front end >  Trigger long process in Django view
Trigger long process in Django view

Time:10-18

I have a view (start_job_view) in Django that should trigger a very long process. I'd like the view to return immediately and add a message to the user ("your job has started" using the message framework) and I'd like that when the long process terminates it sends a new message to the user ("your job has finished").

How can I do this?

Note: I am not keen to add Celery to my project for this only task...

CodePudding user response:

One option is to use async view. You can have more details over here

Another can be creating a celery task and calling it in your view.

CodePudding user response:

You can use in-memory queue which runs on separate thread. Take a look at segment library code, which merge/process events in bg thread here.

Note that in case your server get terminated due to any reason you have mechanism to id job failed and retry.

  • Related