Задача Celery просто пропускает или не выполняет задачу в Django

У меня небольшой опыт работы с Celery и, возможно, я делаю что-то не так. В views.py вызовите задачу celery

def create(self, request, *args, **kwargs):
    instance = self.get_object()

    serializer = self.get_serializer(instance, data=request.data)
    serializer.is_valid(raise_exception=True)

    matching_fields = serializer.validated_data['matching_fields']
    add.apply_async((matching_fields, instance, request), serializer='my_custom_excel')

    return Response(status=201, data={
        'success': True
    })

это мой tasks.py

def my_custom_excel_encoder(obj):
    """Uncomment this block if you intend to pass it as a Base64 string:
    file_base64 = base64.b64encode(obj[0][0]).decode()
    obj = list(obj)
    obj[0] = [file_base64]
    """
    return str(obj)


def my_custom_excel_decoder(obj):
    obj = ast.literal_eval(obj)
    """Uncomment this block if you passed it as a Base64 string (as commented above in the encoder):
    obj[0][0] = base64.b64decode(obj[0][0])
    """
    return obj


register(
    'my_custom_excel',
    my_custom_excel_encoder,
    my_custom_excel_decoder,
    content_type='application/x-my-custom-excel',
    content_encoding='utf-8',
)

app = Celery('tasks')

app.conf.update(
    accept_content=['json', 'my_custom_excel'],
)

@app.task
def add(matching_fields, instance, request):
    helper = ImportData(matching_fields, instance, request)
    helper.import_data()

классу ImportData мы передаем аргументы файла excel, ImportData - это вспомогательный класс для импорта excel. Проблема в том, что моя задача на celery не запускается

Вернуться на верх