why django celery beat worker not relaying expected tasks data

28 views Asked by At

hello everyone i'm trying to perform a task like an APY(annual percentage yield) kind of funtionality, where my user savings will increase by a certain percentage at an interval(monthly or by seconds). my beat scheduler is working but the worker is not returning the expected output in the terminal, nor is it altering the value

MODELS.PY

 def save(self,*args,**kwargs):

        
        if self.funds == '' or self.funds is None:
            self.funds=0
        if self.referrer_bonus== '' or self.referrer_bonus is None:
            self.referrer_bonus=0
        if self.total== '' or  self.total is None:
            self.total=0

        if self.bonus== '' or  self.total is None:
            self.bonus=0
        self.bonus=int(self.referrer_bonus)*15/100
        
        if self.withdrawn == False:
            # self.total=(int(self.funds)*15/100 * int(self.funds))+self.bonus
            self.total=int(self.funds)+self.bonus
        interval=IntervalSchedule.objects.get(every=20,period='seconds')
        if self.total != 0 and self.funds!=0:
                PeriodicTask.objects.create(
                interval=interval,
                name=f'{self.user.email} investment increment',
                task='increment_user_funds',
                start_time=self.timestamp,
                args=json.dumps([self.total,self.funds]),
                )
                # increment_user_funds(self)
            
 
        super().save(*args,**kwargs)

CELERY.PY

from __future__ import absolute_import,unicode_literals
from celery import Celery
import os
from celery import shared_task
from django.conf import settings
from celery.schedules import crontab

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rawfx.settings')

app = Celery('rawfx')

app.config_from_object('django.conf:settings', namespace='CELERY')

# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.autodiscover_tasks()

TASK.PY

from __future__ import absolute_import,unicode_literals

from celery import Celery from celery import shared_task from rawfx.celery import app

@app.task def increment_user_funds(total,funds): total=int(total)+int(funds)*15 print(total) return total

below is the picture of both my worker and beat

worker

[![beat][2]][2] [2]: https://i.stack.imgur.com/PzZRY.png

0

There are 0 answers