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

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -