Replies: 4 comments 1 reply
-
This feels like the wrong approach, as you'd need to potentially catch multiple exceptions wherever you get the result. I do agree though there needs to be a way of capturing the exception. However it's not simple due to our constraint on JSON-only serialization. We could fairly easily pass through the type of exception which was raised, but we couldn't reliably send other details without resorting to The current compromise is to not store it at all, but log it so it can be captured by error monitoring tooling. I'd love some ideas for how this could be solved! |
Beta Was this translation helpful? Give feedback.
-
Logging only is not an option because setting up logging is a non trivial problem in Python. The stdlib logging module has terrible default and an unintuitive api, and half of the django devs I met don't know how to settings.LOGGING work. I do believe it's great to have it, I always set it up myself with rich on top, but it can't be the only source. One additional info source is to serialize the stack trace to text and store it, with the error datetime, to at least be able to read it from the task result later. It's not perfect, but it will allow displaying it in a shell, print it, create an admin for it, etc. We could go as far as dumping the repr() of locals() (barring a size limit) in another attribute. Having a dead letter queue with a live shell is also great for debugging, nothing beats having access to the object in memory, and no serialization is involved, but it's much harder to pull off, especially since it means dealing with a dead letter queue per process. Both is ideal but I understand even if django mascot is a poney, we can't always have one. |
Beta Was this translation helpful? Give feedback.
-
From a design perspective, maybe it's better to:
Because trying to cater to everything may require indeed big dependencies. |
Beta Was this translation helpful? Give feedback.
-
I've written a fairly basic exception serializer which can be used to store task errors: #68 |
Beta Was this translation helpful? Give feedback.
-
Some queue libs do something quite handy, when getting the result of task, if the task raised an exception, then getting the result raises the same exception.
This allows to deal with errors in a natural way with multiple try/except (so good idea support, natural pattern matching, log support), and to debug errors that happen in the other process.
I don't know if this makes sense for django.tasks, but we do need:
Because debugging task queue errors in production is very hard without it, especially if you don't have good telemetry.
Beta Was this translation helpful? Give feedback.
All reactions