Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support kombu serialization and deserialization #15

Open
Shaokun-X opened this issue Oct 11, 2024 · 1 comment
Open

Support kombu serialization and deserialization #15

Shaokun-X opened this issue Oct 11, 2024 · 1 comment

Comments

@Shaokun-X
Copy link

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
Copy link
Author

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

@Shaokun-X Shaokun-X reopened this Oct 24, 2024
@Shaokun-X Shaokun-X changed the title Support kombu serialization Support kombu serialization and deserialization Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant