Bird
0
0

Identify the problem in this async Flask route:

medium📝 Debug Q7 of 15
Flask - Ecosystem and Patterns
Identify the problem in this async Flask route:
from flask import Flask
import asyncio
app = Flask(__name__)

@app.route('/wait')
async def wait():
    asyncio.sleep(1)
    return 'Waited'
AMissing await before asyncio.sleep
BUsing async def without route decorator
CReturning string instead of JSON
DFlask does not support async routes
Step-by-Step Solution
Solution:
  1. Step 1: Check async call usage

    The coroutine asyncio.sleep(1) must be awaited to pause execution properly.
  2. Step 2: Identify missing await

    Without await, the coroutine is created but not executed, causing unexpected behavior.
  3. Final Answer:

    Missing await before asyncio.sleep -> Option A
  4. Quick Check:

    Await all async calls inside async functions [OK]
Quick Trick: Always await async calls inside async functions [OK]
Common Mistakes:
MISTAKES
  • Calling async functions without await
  • Assuming async def alone runs coroutines
  • Ignoring coroutine execution requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes