You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some context on what we were trying to achieve;
We were building a custom Sentry Integration for TaskIq that would add tracing meta-data as labels to queued messages, to achieve this we patched AsyncKicker.kiq and Receiver.run_task methods to add tracing info to message labels which would track tasks from when there were submitted to when a worker picks up and processes the message.
The above test case fails because after the second task is submitted all other subsequent tasks will have a trcae_id of 22222.
Our current workaround is to use a custom task class which doesn't mutate the original task labels
classCustomTask(AsyncTaskiqDecoratedTask):
defkicker(self) ->AsyncKicker[_FuncParams, _ReturnType]:
""" This function returns kicker object. Kicker is a object that can modify kiq request before sending it. :return: AsyncKicker instance. """returnAsyncKicker(
task_name=self.task_name,
broker=self.broker,
labels=deepcopy(self.labels),
)
broker.decorator_class=CustomTask
changed the title [-]AsyncTaskiqDecoratedTask().kicker().with_labels() mutates task labels[/-][+]`AsyncTaskiqDecoratedTask().kicker().with_labels()` mutates task labels[/+]on Mar 1, 2024
You're completely right. If you want to become a contributor, you can create a PR that fixes it. I haven't experienced this problem yet, but I think it's a possible bug.
Thanks for noticing. If you don't want to create a PR, I can create a patch myself.
Activity
[-]AsyncTaskiqDecoratedTask().kicker().with_labels() mutates task labels[/-][+]`AsyncTaskiqDecoratedTask().kicker().with_labels()` mutates task labels[/+]s3rius commentedon Mar 8, 2024
You're completely right. If you want to become a contributor, you can create a PR that fixes it. I haven't experienced this problem yet, but I think it's a possible bug.
Thanks for noticing. If you don't want to create a PR, I can create a patch myself.
donc310 commentedon Mar 8, 2024
Will make PR for the fix.