Closed sanjioh closed 3 years ago
You'll have to set up a custom encoder to be able to serialize UUIDs. See:
https://dramatiq.io/reference.html#dramatiq.Encoder
You can set a custom encoder in your settings using the DRAMATIQ_ENCODER
setting.
@Bogdanp Thanks for your answer.
Just to be sure: is a custom encoder needed even if what’s not json serializable are local variables in the task?
Please note that in the code I provided there’s no UUID in the task argument, it’s a plain dict with both key and value as strings, that shouldn’t have any serialization issue.
The UUID is created in the body of the task, which should be executed in the worker.
Thanks
@sanjioh sorry! I misread your code. I'll take another look this weekend because that is odd.
No problem, thanks for your help! 👍🏻
@sanjioh are you creating/overwriting custom message_ids in one of your middlewares? :)
I took a quick glance into the code and the only situation where this issue might crop up, as far as I can see, is when dramatiq.message.Message
receives a custom message_id
(dramatiq/message.py:78
might be sensible to typecast custom message_id
s @Bogdanp but this also might conflict with customizations...).
Hi @AndreCimander ,
no, I'm not fiddling with message_id
s at all.
The code at the repo https://github.com/sanjioh/django-dramatiq-repro should be enough as a reproducer.
Please let me know if I can be of further help!
Thanks for providing the reproduction repo, @sanjioh . I opened a PR with a fix: https://github.com/sanjioh/django-dramatiq-repro/pull/2
Hi,
first of all, thanks for your work on dramatiq and django-dramatiq.
I'd like to report a strange behaviour of the
AdminMiddleware
, in which it raises an exception upon task serialization.Full reproducer at: https://github.com/sanjioh/django-dramatiq-repro
The core of the problem seems to be in the following files:
views.py
tasks.py
Stacktrace:
Please let me know if I can provide further details.
Thanks, Fabio