carrot.connection — Carrot v0.8.0 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Carrot v0.8.0 documentation »
- API Reference »

# 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, **kwargs)

  A network/socket connection to an AMQP message broker.

  Parameters: | hostname – see `hostname`. userid – see `userid`. password – see `password`. virtual_host – see `virtual_host`. port – see `port`. insist – see `insist`. connect_timeout – see `connect_timeout`. ssl – see `ssl`.

  `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.
  `close`()
    Close the currently open connection.
  `connect`()
    Establish a connection to the AMQP server.
  `create_backend`()
    Create a new instance of the current backend in `backend_cls`.
  `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.

`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).

### Navigation

- index
- modules |
- next |
- previous |
- Carrot v0.8.0 documentation »
- API Reference »