Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Upgrade to celery 5.1.2, flower 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-lane committed Feb 8, 2024
1 parent d2abb22 commit 77a3e65
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ migrate:

.PHONY: celery
celery:
celery worker -A reboot --without-heartbeat --without-gossip --without-mingle
CELERY_TRACE_APP=1 celery --app reboot worker --without-heartbeat --without-gossip --without-mingle

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
worker: celery worker -A reboot --without-heartbeat --without-gossip --without-mingle
worker: celery --app worker --without-heartbeat --without-gossip --without-mingle
web: gunicorn reboot.wsgi --log-level info
4 changes: 2 additions & 2 deletions app/worker/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'''
Module for tasks to be sent on task queue
'''
from celery import task
from celery import shared_task

from app.worker.app_celery import AppTask
from .create_receipt import Receiptor


@task(bind=True, base=AppTask)
@shared_task(bind=True, base=AppTask)
def receiptor(self, queryset, total_count):
receiptor = Receiptor(queryset, total_count)
return receiptor()
4 changes: 2 additions & 2 deletions app/worker/tasks/exporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import csv

from celery import task
from celery import shared_task
from celery.utils.log import get_task_logger
from django.core import serializers
from django.db.models.query import QuerySet
Expand All @@ -10,7 +10,7 @@
from app.worker.app_celery import AppTask, update_percent


@task(bind=True, base=AppTask)
@shared_task(bind=True, base=AppTask)
def exporter(self, file_name, qs: QuerySet = None, total_count: int = 0):
rows = serializers.deserialize('json', qs)
csv_exporter = CsvExporter(file_name, rows, total_count)
Expand Down
5 changes: 3 additions & 2 deletions app/worker/tasks/importers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
Module for csv file importers to be sent to queue
"""
from celery import task
from celery import shared_task

from app.worker.app_celery import AppTask

from .historical_data_importer import HistoricalDataImporter


@task(bind=True, base=AppTask)
@shared_task(bind=True, base=AppTask)
def historical_data_importer(self, csvpath):
importer = HistoricalDataImporter(csvpath)
importer()
2 changes: 1 addition & 1 deletion reboot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ['celery_app']
__all__ = ('celery_app',)
13 changes: 9 additions & 4 deletions reboot/celery.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from celery import Celery
from django.conf import settings
import os

from celery import Celery

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

app = Celery()
app = Celery('reboot')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
app.config_from_object('reboot.celeryconfig')

app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
# Load task modules from all registered Django apps.
app.autodiscover_tasks()
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Commented requirements indicate the latest patches of the earliest releases that support Python 3.9.

# https://pypi.org/project/celery/5.1.2/
# celery[redis]==5.1.2
celery[redis]==4.4.7
celery[redis]==5.1.2
# https://pypi.org/project/Django/2.2.28/
Django==2.2.28
# https://pypi.org/project/dj-database-url/1.0.0/
Expand All @@ -15,8 +14,7 @@ django-admin-rangefilter==0.8.8
# https://pypi.org/project/django-modeladmin-reorder/0.3.1/
django-modeladmin-reorder==0.3.1
# https://pypi.org/project/flower/1.0.0/
# flower==1.0.0
flower==0.9.7
flower==1.0.0
# https://pypi.org/project/gunicorn/20.1.0/
gunicorn==20.1.0
# https://pypi.org/project/importlib-metadata/4.8.3/
Expand Down

0 comments on commit 77a3e65

Please sign in to comment.