Normal Celery tasks support using kombu to register object types to serialize/deserialize automatically:
from kombu.utils.json import register_type
from django.db.models import Model
from django.apps import apps
# Allow serialization of django models:
register_type(
Model,
"model",
lambda o: [o._meta.label, o.pk],
lambda o: apps.get_model(o[0]).objects.get(pk=o[1]),
)
@shared_task
def mytask(model: Model):
# this will be the restored the object
print(type(model))
But it seems celery_longterm_scheduler is not taking it into account. Is it possible to add this feature?
Normal Celery tasks support using
kombu
to register object types to serialize/deserialize automatically:But it seems
celery_longterm_scheduler
is not taking it into account. Is it possible to add this feature?kombu
doc: https://docs.celeryq.dev/projects/kombu/en/stable/userguide/serialization.html