update celery call
This commit is contained in:
parent
288abf1ad0
commit
3a48ac9c6b
@ -3,6 +3,10 @@ from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from datetime import datetime
|
||||
from . import utils
|
||||
from . import tasks
|
||||
from caromserver import celery
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
|
||||
|
||||
class LocationData(models.Model):
|
||||
@ -87,3 +91,9 @@ class Accounting(models.Model):
|
||||
ordering = ['-time_from']
|
||||
verbose_name = "Buchhaltungseintrag"
|
||||
verbose_name_plural = "Buchhaltungseinträge"
|
||||
|
||||
|
||||
def update_location_data(sender, instance, **kwargs):
|
||||
tasks.process_location_data.delay()
|
||||
|
||||
post_save.connect(update_location_data, sender=LocationData)
|
||||
|
@ -4,5 +4,9 @@ from . import models
|
||||
|
||||
|
||||
@shared_task
|
||||
def add(x, y):
|
||||
return x + y
|
||||
def process_location_data():
|
||||
data = models.LocationData.objects.filter(processed=False)
|
||||
print(len(data))
|
||||
for ld in data:
|
||||
print(ld)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
import os
|
||||
import django
|
||||
from celery import Celery
|
||||
|
||||
# set the default Django settings module for the 'celery' program.
|
||||
@ -14,7 +15,11 @@ app = Celery('caromserver')
|
||||
app.config_from_object('django.conf:settings')
|
||||
|
||||
# Load task modules from all registered Django app configs.
|
||||
#app.autodiscover_tasks()
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caromserver.settings")
|
||||
django.setup()
|
||||
|
||||
app.autodiscover_tasks(['billard'])
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
|
Loading…
Reference in New Issue
Block a user