taskiq-python / taskiq

Distributed task queue with full async support
MIT License
871 stars 53 forks source link

Set the task name as task_id #361

Closed realitix closed 2 months ago

realitix commented 2 months ago

Hello and thank you for Taskiq, which is really well made.

Would it be possible to add the task_id as the task name? This would make it easier to retrieve the task ID directly from the task itself. I use this feature to capture all logs associated with a task using Loguru, and I rely on the task name for that. Then, I associate it with the task_id from Taskiq.

Thanks

s3rius commented 2 months ago

Thanks for your words. I don't think it is possible, because task names are used for function resolving which function to run. Although if you just want to get the task id from inside the task, then you can easily use context for that purpose. As far as I understood the problem, it should be enough.

https://taskiq-python.github.io/guide/architecture-overview.html#context

realitix commented 2 months ago

Finally I do it in my middleware pre_execute