carrot.connection

Getting a connection to the AMQP server.

carrot.connection.AMQPConnection

alias of BrokerConnection

class carrot.connection.BrokerConnection(hostname=None, userid=None, password=None, virtual_host=None, port=None, pool=None, **kwargs)

A network/socket connection to an AMQP message broker.

Parameters:
hostname

The hostname to the AMQP server

userid

A valid username used to authenticate to the server.

password

The password used to authenticate to the server.

virtual_host

The name of the virtual host to work with. This virtual host must exist on the server, and the user must have access to it. Consult your brokers manual for help with creating, and mapping users to virtual hosts. Default is "/".

port

The port of the AMQP server. Default is 5672 (amqp).

insist

Insist on connecting to a server. In a configuration with multiple load-sharing servers, the insist option tells the server that the client is insisting on a connection to the specified server. Default is False.

connect_timeout

The timeout in seconds before we give up connecting to the server. The default is no timeout.

ssl

Use SSL to connect to the server. The default is False.

backend_cls

The messaging backend class used. Defaults to the pyamqplib backend.

ConnectionException

alias of AMQPConnectionException

channel()

For Kombu compatibility.

channel_errors

List of exceptions that may be raised by the channel.

close()

Close the currently open connection.

connect()

Establish a connection to the AMQP server.

connection
connection_errors

List of exceptions that may be raised by the connection.

create_backend()

Create a new instance of the current backend in backend_cls.

drain_events(**kwargs)
ensure_connection(errback=None, max_retries=None, interval_start=2, interval_step=2, interval_max=30)

Ensure we have a connection to the server.

If not retry establishing the connection with the settings specified.

Parameters:
  • errback – Optional callback called each time the connection can’t be established. Arguments provided are the exception raised and the interval that will be slept (exc, interval).
  • max_retries – Maximum number of times to retry. If this limit is exceeded the connection error will be re-raised.
  • interval_start – The number of seconds we start sleeping for.
  • interval_step – How many seconds added to the interval for each retry.
  • interval_max – Maximum number of seconds to sleep between each retry.
get_backend_cls()

Get the currently used backend class.

get_channel()

Request a new AMQP channel.

host

The host as a hostname/port pair separated by colon.

info()

Get connection info.

release()
exception carrot.connection.ConnectionLimitExceeded

The maximum number of pool connections has been exceeded.

class carrot.connection.ConnectionPool(source_connection, min=2, max=None, preload=True)
acquire(block=False, timeout=None, connect_timeout=None)
release(connection)
carrot.connection.DjangoAMQPConnection

alias of DjangoBrokerConnection

class carrot.connection.DjangoBrokerConnection(*args, **kwargs)

A version of BrokerConnection that takes configuration from the Django settings.py module.

Parameters:
  • hostname – The hostname of the AMQP server to connect to, if not provided this is taken from settings.BROKER_HOST.
  • userid – The username of the user to authenticate to the server as. If not provided this is taken from settings.BROKER_USER.
  • password – The users password. If not provided this is taken from settings.BROKER_PASSWORD.
  • virtual_host – The name of the virtual host to work with. This virtual host must exist on the server, and the user must have access to it. Consult your brokers manual for help with creating, and mapping users to virtual hosts. If not provided this is taken from settings.BROKER_VHOST.
  • port – The port the AMQP server is running on. If not provided this is taken from settings.BROKER_PORT, or if that is not set, the default is 5672 (amqp).
carrot.connection.get_django_conninfo(settings=None)

Previous topic

API Reference

Next topic

carrot.messaging

This Page