RealOrangeOne / django-tasks

A reference implementation and backport of background workers and tasks in Django
https://pypi.org/project/django-tasks/
BSD 3-Clause "New" or "Revised" License
314 stars 22 forks source link

Dummy and immediate backends should serialize arguments #23

Closed adamchainz closed 3 months ago

adamchainz commented 3 months ago

These two backends should serialize args and kwargs with json.dumps, even if not storing them. This will validate that the arguments are compatible with DatabaseBackend or other backends.

I have seen the lack of serialization as an issue on other task queue systems. Tests using a dummy backend skipped serialization, so they didn’t find unserializable arguments, leading to a crash in production.

RealOrangeOne commented 3 months ago

I completely agree. Prior to #3, there was no serialization done on arguments, which diverts from the spec. As part of #3, arguments are serialized (and normalized) to ensure the values of args and kwargs are consistent between backends.

https://github.com/RealOrangeOne/django-tasks/blob/7e0024bf1e01eda40d1808898c19bb5df835f9b9/django_tasks/backends/dummy.py#L36-L37

adamchainz commented 3 months ago

Nicely done, thanks!