Inside celery Task Class run method get task_id -
i trying run following code:
class mytask(task): def run(): print mytask.request.id
but code giving none request_id. please explain me why not able read id in side celery task class
you trying access request object on class not object instance. try this:
class mytask(task): def run(self, *args, **kwargs): print self.request.id
you can use @task
decorator:
app = celery('tasks', broker='amqp://guest@localhost//') @app.task(bind=true) def mytask(self): print self.request.id
Comments
Post a Comment