1

I have two environments
1. webserver
2. celery worker

webserver add jobs to celery message queue. but those env are separated, so can not import task function.

how to call not exist task explicitly?

ex)

# A project (web) - view.py
def view(request): 
    [X] task_a.delay()  
    [O] add_jobs("task_a", *args)
    ...

# B project (worker) - tasks.py
@task
def task_a:
    ...

1
  • 1
    Please, give us more details. Improve your question. If you use task.delay(), in your task you have to put a decorator @task, by celery Commented Nov 7, 2019 at 16:23

1 Answer 1

2

Use the send_task function to send a task to a decoupled celery project.

from celery.app import Celery
app = Celery(broker_url='the broker url of the celery instance')
app.send_task(name='myapp.mytaskname', kwargs={
  'arg1': 'value1',
  'arg2': 'value2',
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.