Support kombu serialization and deserialization
Opened this issue · 1 comments
Shaokun-X commented
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?
kombu
doc: https://docs.celeryq.dev/projects/kombu/en/stable/userguide/serialization.html
Shaokun-X commented
After some more testing, I think with celery_longterm_scheduler
, kombu
deserialization is not working properly