Open gameveloster opened 1 year ago
Also there is an import:
from notifications.models import PushToken
What is this notifications models that is being imported?
We would appreciate it if the author answered the question on where self.retry comes from
This looks like it was lifted from a Celery task.
Typically, you want to send push notifications in the background, and Celery is a tool for background tasks. You gain access to the self
keyword from the Celery decorator, which would look something like this:
@app.task(
bind=True,
max_retries=5,
default_retry_delay=10,
ignore_result=True,
)
def send_push_message(self, token, message, extra=None):
...
if error:
self.retry(...)
When the task fails, you can use self.retry(...)
to reschedule it. Here are the docs: https://docs.celeryq.dev/en/stable/index.html
bind=True
provides the self
parameter which gives you access to the task's meta info. Here are the docs: https://docs.celeryq.dev/en/stable/userguide/tasks.html#bound-tasks
In the example in the
README
, the code has two occurance of:Where is the
retry
method defined in the example, and why is it usingself.retry
when it is not called from inside a class method?