Closed danilaeremin closed 4 years ago
I think it might be cleaner then to simply provide job_id
as the first positional argument. Users of the tasks module would then have to update their code.
Yes, it's simplest solution (actually I have such changes locally) I will create Pull Request
Any mechanism for getting task id in executor.
I can get it via inspect module (get local variable
job
inQueue.perform
). But it's not very good approach.I see several ways of implementation: 1) Thread-local variable and job_id property. It's not safe in async functions 2) Same as 1) but with contextvars module. This will require Python 3.7 or back port module. 3) Determine if function has keyword argument
job_id
and pass it in such case.I can make pull request with any of the options if will be decision about implementation.