Skip to content

Exceptions

rabbitpy contains two types of exceptions: exceptions specific to rabbitpy and exceptions raised as a result of a Channel or Connection closure from RabbitMQ.

Example

import rabbitpy

try:
    with rabbitpy.Connection() as connection:
        with connection.channel() as channel:
            queue = rabbitpy.Queue(channel, 'exception-test')
            queue.durable = True
            queue.declare()
            queue.durable = False
            queue.declare()  # raises AMQPPreconditionFailed
except rabbitpy.exceptions.AMQPPreconditionFailed:
    print('Queue already exists with different parameters')

rabbitpy Exceptions

rabbitpy.exceptions.RabbitpyException

Bases: Exception

Base exception for all rabbitpy exceptions.

rabbitpy.exceptions.ActionException

Bases: RabbitpyException

Raised when an action is taken on a Rabbitpy object that is not supported due to the state of the object. An example would be trying to ack a Message object when the message object was locally created and not sent by RabbitMQ via an AMQP Basic.Get or Basic.Consume.

rabbitpy.exceptions.ChannelClosedException

Bases: RabbitpyException

Raised when an action is attempted on a channel that is closed.

rabbitpy.exceptions.ConnectionException

Bases: RabbitpyException

Raised when Rabbitpy can not connect to the specified server and if a connection fails and the RabbitMQ version does not support the authentication_failure_close feature added in RabbitMQ 3.2.

rabbitpy.exceptions.ConnectionClosed

Bases: ConnectionException

Raised if a connection.close() is invoked when the connection is not open.

rabbitpy.exceptions.ConnectionResetException

Bases: ConnectionException

Raised if the socket level connection was reset. This can happen due to the loss of network connection or socket timeout, or more than 2 missed heartbeat intervals if heartbeats are enabled.

rabbitpy.exceptions.MessageReturnedException

Bases: RabbitpyException

Raised if the RabbitMQ sends a message back to a publisher via the Basic.Return RPC call.

rabbitpy.exceptions.NoActiveTransactionError

Bases: RabbitpyException

Raised when a transaction method is issued but the transaction has not been initiated.

rabbitpy.exceptions.NotConsumingError

Bases: RabbitpyException

Raised Queue.cancel_consumer() is invoked but the queue is not actively consuming.

rabbitpy.exceptions.NotSupportedError

Bases: RabbitpyException

Raised when a feature is requested that is not supported by the RabbitMQ server.

rabbitpy.exceptions.ReceivedOnClosedChannelException

Bases: RabbitpyException

Raised when RabbitMQ sends an RPC on a channel that is closed.

rabbitpy.exceptions.RemoteCancellationException

Bases: RabbitpyException

Raised if RabbitMQ cancels an active consumer

rabbitpy.exceptions.RemoteClosedChannelException

Bases: RabbitpyException

Raised if RabbitMQ closes the channel and the reply_code in the Channel.Close RPC request does not have a mapped exception in Rabbitpy.

rabbitpy.exceptions.RemoteClosedException

Bases: RabbitpyException

Raised if RabbitMQ closes the connection and the reply_code in the Connection.Close RPC request does not have a mapped exception in Rabbitpy.

rabbitpy.exceptions.TooManyChannelsError

Bases: RabbitpyException

Raised if an application attempts to create a channel, exceeding the maximum number of channels (MAXINT or 2,147,483,647) available for a single connection. Note that each time a channel object is created, it will take a new channel id. If you create and destroy 2,147,483,648 channels, this exception will be raised.

rabbitpy.exceptions.UnexpectedResponseError

Bases: RabbitpyException

Raised when an RPC call is made to RabbitMQ but the response it sent back is not recognized.

AMQP Exceptions

These exceptions are raised when RabbitMQ sends a channel or connection close with a specific AMQP reply code.

rabbitpy.exceptions.AMQPException

Bases: RabbitpyException

Base exception for all AMQP exceptions.

rabbitpy.exceptions.AMQPAccessRefused

Bases: AMQPException

The client attempted to work with a server entity to which it has no access due to security settings.

rabbitpy.exceptions.AMQPChannelError

Bases: AMQPException

The client attempted to work with a channel that had not been correctly opened. This most likely indicates a fault in the client layer.

rabbitpy.exceptions.AMQPCommandInvalid

Bases: AMQPException

The client sent an invalid sequence of frames, attempting to perform an operation that was considered invalid by the server. This usually implies a programming error in the client.

rabbitpy.exceptions.AMQPConnectionForced

Bases: AMQPException

An operator intervened to close the connection for some reason. The client may retry at some later date.

rabbitpy.exceptions.AMQPContentTooLarge

Bases: AMQPException

The client attempted to transfer content larger than the server could accept at the present time. The client may retry at a later time.

rabbitpy.exceptions.AMQPFrameError

Bases: AMQPException

The sender sent a malformed frame that the recipient could not decode. This strongly implies a programming error in the sending peer.

rabbitpy.exceptions.AMQPInternalError

Bases: AMQPException

The server could not complete the method because of an internal error. The server may require intervention by an operator in order to resume normal operations.

rabbitpy.exceptions.AMQPInvalidPath

Bases: AMQPException

The client tried to work with an unknown virtual host.

rabbitpy.exceptions.AMQPNoConsumers

Bases: AMQPException

When the exchange cannot deliver to a consumer when the immediate flag is set. As a result of pending data on the queue or the absence of any consumers of the queue.

rabbitpy.exceptions.AMQPNoRoute

Bases: AMQPException

Undocumented AMQP Soft Error

rabbitpy.exceptions.AMQPNotAllowed

Bases: AMQPException

The client tried to work with some entity in a manner that is prohibited by the server, due to security settings or by some other criteria.

rabbitpy.exceptions.AMQPNotFound

Bases: AMQPException

The client attempted to work with a server entity that does not exist.

rabbitpy.exceptions.AMQPNotImplemented

Bases: AMQPException

The client tried to use functionality that is not implemented in the server.

rabbitpy.exceptions.AMQPPreconditionFailed

Bases: AMQPException

The client requested a method that was not allowed because some precondition failed.

rabbitpy.exceptions.AMQPResourceError

Bases: AMQPException

The server could not complete the method because it lacked sufficient resources. This may be due to the client creating too many of some type of entity.

rabbitpy.exceptions.AMQPResourceLocked

Bases: AMQPException

The client attempted to work with a server entity to which it has no access because another client is working with it.

rabbitpy.exceptions.AMQPSyntaxError

Bases: AMQPException

The sender sent a frame that contained illegal values for one or more fields. This strongly implies a programming error in the sending peer.

rabbitpy.exceptions.AMQPUnexpectedFrame

Bases: AMQPException

The peer sent a frame that was not expected, usually in the context of a content header and body. This strongly indicates a fault in the peer's content processing.