Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make specific background task in Django?

I have a mission to make a background task in Django, I tried with celery but I didn’t have success.

What I have to do? I need after the person wrote the number in input and pressed submit button, for example 100, the 1% of it will be added every second to his previous number during the 1 day.

  1. He wrote in input 100
  2. In database this is stored, and in during a day, every second is adding 1%.
  3. How concretely it looks, 100+1=101, 101+1=102, 102+1…. every second adding 1%

Can you help me draw the code what it looks like? With celery, django-background-task or others doesn’t matter, the main importance that it needs to be certain number of tasks simultaneously, for every user his background task

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you could use a package called django-background-tasks

and your function will be like this:

from background_task import background

@background(schedule=60)
def add(input): # this function will run every 60 seconds
    input += (input*0.01)

link for the package docs

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading