これは、チャネルが完全に閉じられる前に BlockingConnection を閉じると、RabbitMQ 3.3.3 で発生します。解決策は、チャネルの close-callback で接続を閉じることです。また、コンテキスト マネージャーを使用して、チャネルを自動的に閉じます。
params = pika.ConnectionParameters(host=self._host, port=self._port)
connection = pika.BlockingConnection(params)
with contextlib.closing(connection.channel()) as channel:
# Close connection once channel is closed
def closeConnection(channel, replyCode, replyText):
connection.close()
channel.add_on_close_callback(closeConnection)
# Declare a durable queue; we will use the default exchange for
# simple key-based routing
channel.queue_declare(queue=self._queueName, durable=True)
...
...