Bird
0
0

What is wrong with this Redis publish code in Flask? ```python redis_client.publish(channel='alerts', message='Warning') ```

medium📝 Debug Q7 of 15
Flask - Background Tasks
What is wrong with this Redis publish code in Flask? ```python redis_client.publish(channel='alerts', message='Warning') ```
AThe message must be a list, not a string
BThe channel name must be bytes, not string
Cpublish() does not accept keyword arguments
Dpublish() requires a callback function
Step-by-Step Solution
Solution:
  1. Step 1: Review redis-py publish method signature

    publish(channel, message) expects positional arguments, not keywords.
  2. Step 2: Check other options

    Channel and message can be strings. No callback needed. Message can be string.
  3. Final Answer:

    publish() does not accept keyword arguments -> Option C
  4. Quick Check:

    publish uses positional args only [OK]
Quick Trick: Use positional args for publish(channel, message) [OK]
Common Mistakes:
MISTAKES
  • Using keyword arguments with publish
  • Thinking channel must be bytes
  • Expecting publish to take callbacks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes