add task handler
This commit is contained in:
parent
93903e23fb
commit
3eb963736d
1
Pipfile
1
Pipfile
@ -13,3 +13,4 @@ django-extensions = "==3.1.3"
|
|||||||
django-tables2 = "==2.4.1"
|
django-tables2 = "==2.4.1"
|
||||||
djangorestframework = "==3.12.4"
|
djangorestframework = "==3.12.4"
|
||||||
requests = "==2.26.0"
|
requests = "==2.26.0"
|
||||||
|
django-simple-task = "==0.1.2"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
from django_simple_task import defer
|
||||||
|
|
||||||
from billard.models import LocationData
|
from billard.models import LocationData
|
||||||
from billard.tasks import process_location_data
|
from billard.tasks import process_location_data
|
||||||
@ -7,4 +8,4 @@ from billard.tasks import process_location_data
|
|||||||
|
|
||||||
@receiver(post_save, sender=LocationData)
|
@receiver(post_save, sender=LocationData)
|
||||||
def update_location_data(sender, instance, **kwargs):
|
def update_location_data(sender, instance, **kwargs):
|
||||||
process_location_data(sender=sender, kwargs=kwargs)
|
defer(process_location_data(sender=sender, kwargs=kwargs))
|
||||||
|
@ -10,7 +10,9 @@ https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
from django_simple_task import django_simple_task_middlware
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'caromserver.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'caromserver.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
||||||
|
application = django_simple_task_middlware(application)
|
||||||
|
@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
|||||||
# third party apps
|
# third party apps
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
|
'django_simple_task',
|
||||||
'django_tables2',
|
'django_tables2',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'rest_framework.authtoken',
|
'rest_framework.authtoken',
|
||||||
|
Loading…
Reference in New Issue
Block a user