Consider this code:
from pydantic import BaseModel
class MyModel(BaseModel):
x: int
appc = Celery(...)
@appc.task(bind=True)
def mytask(self):
return [MyModel(x=0)]
res = mytask.delay().get() # ERROR
Error is: kombu.exceptions.EncodeError: TypeError('Object of type MyModel is not JSON serializable')
I tried working with kombu serializers or with pydantic encoder but I really don't understand what is going wrong.
List[Dict]
instead ofList[MyModel]
loosing all the benefits of pydantic... – Doti