Home > other >  How to make specific background task in Django?
How to make specific background task in Django?

Time:10-27

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

CodePudding user response:

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

  • Related