novacode-nl / odoo-celery

Odoo & Celery integration
GNU Lesser General Public License v3.0
42 stars 44 forks source link

A problem When I Calling Tasks #6

Closed sehngya closed 5 years ago

sehngya commented 5 years ago

Hi ,Bob! I've got a problem and as I don't know what to do I thought I'd write to you and ask for your advice. When i calling tasks(i only set celery broker to redis ),the following error occurs Traceback (most recent call last): File "d:\anaconda3\envs\odoo3.5\lib\site-packages\celery\app\trace.py", line 382, in trace_task R = retval = fun(*args, *kwargs) File "d:\anaconda3\envs\odoo3.5\lib\site-packages\celery\app\trace.py", line 641, in __protected_call__ return self.run(args, **kwargs) TypeError: call_task() missing 1 required positional argument: 'method'

bobslee commented 5 years ago

Hi @sehngya. According to the trace I suppose the call_task method misses the second argument method. Did you already checked the "celery_example" module, with some call_task calls implemented? Check over here: https://github.com/novacode-nl/odoo-celery/blob/12.0/celery_example/models/celery_example.py

I hope you'll get it, otherwise let me know.

Cheers, Bob

sehngya commented 5 years ago

I'm sorry,I checked the "celery_example" module,I set argument method and it's doesn't work @api.multi def action_queue_example_line(self): try: self.env["celery.task"].call_task("celery.example", "queue_example_line", example_id=self.id) except Exception as e: _logger.error(e)

bobslee commented 5 years ago

Did you setup a running Celery server/worker? You completed all steps in the documentation?

sehngya commented 5 years ago

Yes, I just solved the problem.In method call_task ,if I set bind=False,The problem arises. I alter bind=True,the problem been gone and i don't know why

bobslee commented 5 years ago

Please could you send or show me the piece of code/call?

sehngya commented 5 years ago

@bobslee Thank you very much. I will try to find out the reason

sehngya commented 5 years ago

@bobslee Yes,of course.

bobslee commented 5 years ago

@sehngya There's a reason the Celery Task (dispatcher function) is a bounded task. It's especially needed for retries in this module. More info about bound tasks: http://docs.celeryproject.org/en/latest/userguide/tasks.html#bound-tasks

sehngya commented 5 years ago

@bobslee Thank you for your help.