Recall & Review
beginner
What is a task in Django when using Celery?
A task is a Python function that runs asynchronously in the background, outside the normal request-response cycle, to perform time-consuming or scheduled work.
Click to reveal answer
beginner
How do you define a simple Celery task in Django?
You define a Celery task by creating a Python function and decorating it with
@app.task where app is your Celery application instance.Click to reveal answer
intermediate
Why should tasks be idempotent in Django Celery?
Tasks should be idempotent so that running them multiple times does not cause unintended side effects, ensuring reliability if a task is retried or duplicated.
Click to reveal answer
beginner
What is the purpose of the
delay() method when calling a Celery task?The
delay() method sends the task to the Celery worker to run asynchronously, instead of running it immediately in the current process.Click to reveal answer
beginner
Where do you usually place task definitions in a Django project?
Tasks are usually placed in a
tasks.py file inside a Django app folder to keep task code organized and close to related app logic.Click to reveal answer
Which decorator is used to define a Celery task in Django?
✗ Incorrect
The correct decorator to define a Celery task is
@app.task, where app is your Celery application instance.What does calling
my_task.delay() do?✗ Incorrect
Calling
delay() sends the task to a Celery worker to run asynchronously in the background.Why is it important for tasks to be idempotent?
✗ Incorrect
Idempotency ensures tasks can be safely retried or duplicated without causing errors or unwanted changes.
Where should you place task definitions in a Django app?
✗ Incorrect
Tasks are best organized in a
tasks.py file inside the Django app folder.What is the main benefit of defining tasks in Django with Celery?
✗ Incorrect
Defining tasks lets you run slow or heavy work in the background, so the website stays fast and responsive.
Explain how to define and call a simple Celery task in a Django project.
Think about how you tell Celery which function is a task and how you ask it to run later.
You got /3 concepts.
Why should tasks be idempotent and where do you place them in a Django app?
Consider reliability and project organization.
You got /2 concepts.