Bird
0
0

Given the following Python code snippet using pika:

medium📝 Command Output Q13 of 15
RabbitMQ - Performance Tuning
Given the following Python code snippet using pika:
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters())
channel1 = connection.channel()
channel2 = connection.channel()
print(channel1.is_open, channel2.is_open)
channel1.close()
print(channel1.is_open, channel2.is_open)
What will be the output?
ATrue False\nFalse False
BTrue True\nFalse False
CFalse False\nFalse False
DTrue True\nFalse True
Step-by-Step Solution
Solution:
  1. Step 1: Check initial channel states

    Both channels are open after creation, so first print shows True True.
  2. Step 2: Close channel1 and check states

    Closing channel1 sets its is_open to False; channel2 remains open True.
  3. Final Answer:

    True True\nFalse True -> Option D
  4. Quick Check:

    Closing one channel doesn't close others [OK]
Quick Trick: Closing one channel doesn't affect others [OK]
Common Mistakes:
MISTAKES
  • Assuming closing one channel closes all
  • Confusing is_open states after close
  • Expecting both channels to close automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More RabbitMQ Quizzes