maciej-gol / tenant-schemas-celery

MIT License
179 stars 36 forks source link

@shared_task() takes 0 positional arguments but 1 was given #130

Closed vkgautham closed 15 hours ago

vkgautham commented 2 days ago

TypeError at .../ my_shared_task() takes 0 positional arguments but 1 was given

Celery shared_task doesn't take any positional arguments, but the example in documentation binds TenantTask for shared tasks which throws exception.

   from celery import shared_task
   from django.db import connection
   from myproject.celery import app
   from tenant_schemas_celery.task import TenantTask

   @app.task
   def my_task():
      print(connection.schema_name)

   @shared_task(base=TenantTask, bind=True)
   def my_shared_task():
      print("foo")

Any idea?

maciej-gol commented 1 day ago

What's your celery version? It works correctly on 5.4.0 (in tests). See https://github.com/maciej-gol/tenant-schemas-celery/blob/master/tenant_schemas_celery/test_tasks.py#L47

vkgautham commented 15 hours ago

Just "celery" in requirements.txt (Docker) didnt pick up the latest version. Need to explicit version.

Thanks