S
S
Sabrjkee2019-04-11 10:08:23
Django
Sabrjkee, 2019-04-11 10:08:23

How to call a method in Django celery from code?

Good afternoon. I'm trying to create a task that should be called from the start of the walker and then called after a certain time. Here is the task code . When I start the walker, I get this:

[tasks]
  . test_odoo.tasks.populate_db

[2019-04-11 09:59:24,102: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2019-04-11 09:59:24,107: INFO/MainProcess] mingle: searching for neighbors
[2019-04-11 09:59:25,119: INFO/MainProcess] mingle: all alone
[2019-04-11 09:59:25,130: WARNING/MainProcess] /home/user/.virtualenvs/django/lib/python3.6/site-packages/celery/fixups/django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
  warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2019-04-11 09:59:25,130: INFO/MainProcess] [email protected] ready.

if you need to use apply_async then where should it be called

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FulTupFul, 2019-04-11
@Sabrjkee

celerybeat
Specify which task to run and with what frequency:

CELERY_BEAT_SCHEDULE = {
    'task_name': {
        'task': 'app.module.task_name',
        'schedule': timezone.timedelta(minutes=1),
    }
}

Create a task:
from celery import shared_task


@shared_task
def task_name(*args, **kwargs):
    pass

Well, we start the task:
https://docs.celeryproject.org/en/latest/userguide...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question