Bird
0
0

Given this Flask RQ code snippet:

medium📝 component behavior Q4 of 15
Flask - Background Tasks
Given this Flask RQ code snippet:
from rq import Queue
from redis import Redis

redis_conn = Redis()
queue = Queue(connection=redis_conn)
result = queue.enqueue(lambda x: x + 1, 5)
print(result.get(timeout=1))

What will be printed?
ATimeoutError
B5
CNone
D6
Step-by-Step Solution
Solution:
  1. Step 1: Understand enqueue and task

    The lambda adds 1 to input 5, so result should be 6.
  2. Step 2: Check result.get(timeout=1)

    It waits up to 1 second for task completion; task is simple so returns 6.
  3. Final Answer:

    6 -> Option D
  4. Quick Check:

    Task output = 6 [OK]
Quick Trick: Simple tasks return result quickly; get() fetches it [OK]
Common Mistakes:
MISTAKES
  • Confusing input with output
  • Expecting None before task finishes
  • Assuming timeout error for fast tasks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes