pinax-badges icon indicating copy to clipboard operation
pinax-badges copied to clipboard

AttributeError with async_ = True

Open Loneattic opened this issue 4 years ago • 2 comments

TestAsyncBadge
class TestAsyncBadge(Badge):
   async_ = True
   slug = "test_async_badge"
   levels = [
       ...
   ]
   events = [
       "something_awarded",
   ]
   multiple = False

   def award(self, **state):
       ...

badges.register(TestAsyncBadge)

def test_func(self):
  badges.possibly_award_badge("something_awarded", user=self.user)
File "/usr/local/lib/python3.8/dist-packages/celery/app/task.py", line 426, in delay
    return self.apply_async(args, kwargs)
    
AttributeError: 'TestAsyncBadge' object has no attribute 'apply_async'
Celery.py
app = Celery('appname')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

celery 4.4.7

Loneattic avatar Jan 15 '21 03:01 Loneattic

I have the same problem with celery==5.0.5

eon01 avatar Feb 13 '21 02:02 eon01

@Loneattic @eon01 if you can, maybe try the proposed changes in #43 and see if that resolves your issue? You can run:

pip install -e git+https://github.com/piraka9011/pinax-badges.git

piraka9011 avatar Aug 15 '21 15:08 piraka9011