Challenge - 5 Problems
Task Status Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Check Flask task status endpoint output
Given a Flask app with a background task status endpoint, what is the output when the task is still running?
Flask
from flask import Flask, jsonify app = Flask(__name__) tasks = {'task1': 'running'} @app.route('/status/<task_id>') def status(task_id): state = tasks.get(task_id, 'not found') return jsonify({'task_id': task_id, 'status': state}) # Request: GET /status/task1
Attempts:
2 left
💡 Hint
Check the tasks dictionary for the status of 'task1'.
✗ Incorrect
The tasks dictionary has 'task1' with status 'running', so the endpoint returns that status in JSON.
❓ Configuration
intermediate2:00remaining
Configure Flask to run background tasks with status tracking
Which Flask extension and configuration is best suited to run background tasks and monitor their status?
Attempts:
2 left
💡 Hint
Look for a task queue system integrated with Flask.
✗ Incorrect
Flask-Celery with Redis is commonly used to run background tasks and track their status asynchronously.
❓ Troubleshoot
advanced2:00remaining
Troubleshoot missing task status updates in Flask app
A Flask app using Celery to run tasks does not update task status correctly. Which issue is most likely causing this?
Attempts:
2 left
💡 Hint
If tasks never run, status won't update.
✗ Incorrect
If the Celery worker process is not running, tasks are never executed and status remains unchanged.
🔀 Workflow
advanced3:00remaining
Order the steps to implement task status monitoring in Flask
Arrange these steps in the correct order to implement task status monitoring in a Flask app using Celery.
Attempts:
2 left
💡 Hint
Setup first, then task, then status route, then run worker.
✗ Incorrect
First configure Celery, then create tasks, add status route, and finally start the worker to process tasks.
✅ Best Practice
expert3:00remaining
Choose the best practice for scalable task status monitoring in Flask
Which approach is best for scalable and reliable task status monitoring in a Flask app with many concurrent tasks?
Attempts:
2 left
💡 Hint
Think about multiple workers and app instances.
✗ Incorrect
Using an external persistent store like Redis or a database ensures task status is consistent and accessible across multiple workers and app instances.