Skip to content

Support kombu serialization and deserialization #15

Description

@Shaokun-X

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

Activity

  1. Shaokun-X commented on Oct 24, 2024

    @Shaokun-X
    Author

    After some more testing, I think with celery_longterm_scheduler, kombu deserialization is not working properly

  2. changed the title [-]Support kombu serialization[/-] [+]Support kombu serialization and deserialization[/+] on Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions