taskiq
taskiq copied to clipboard
There is no way of sending a task with arbitrary types
So I tried to use PickleSerializer. But it raises SendTaskError without message, which is not quite informative, by the way, so I needed to debug. And turned out formatter tries to dump a message beforehand, and raises PydanticSerializationError ("Unable to serialize unknown type: <my_class>"). So I tried to create my own simple PickleFormatter:
class PickleFormatter(TaskiqFormatter):
def dumps(self, message: TaskiqMessage) -> BrokerMessage:
return BrokerMessage(
task_id=message.task_id,
task_name=message.task_name,
message=pickle.dumps(message),
labels=message.labels,
)
def loads(self, message: bytes) -> TaskiqMessage:
return pickle.loads(message)
And it sends a task, but then a worker raises pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <my_class>.
Any workarounds for that?