taskiq
taskiq copied to clipboard
If label is not str worker fails without traceback
If a label with a type different from str
is added anywhere in the worker task, the task will fail.
@broker.task
async def generation_task(params: RequestParams, context: Annotated[Context, TaskiqDepends()]):
result = do_some_work(params)
context.message.labels['non_str_field'] = 42
return result
I suspect the issue lies in the construction of the TaskiqResult
object at /taskiq/receiver/receiver.py:294
.
While it's acceptable for the task to fail on unknown types, the problem is that it doesn't display anything in the log. This lack of information made it necessary for me to spend extra time figuring out what went wrong.
Perhaps, to make this workaround clearer, we could consider adding some logging?
Totally agree on that one.
That's weird that receiver fails after non-string label. Also we have this PR waiting to be merged that might solve your issue as well.
https://github.com/taskiq-python/taskiq/pull/243