def __init__(self, host, credentials, queue, binds=None, prefetch_count=4):
		"""
		Initialize AMQP connection.

		Parameters
		----------
		host: tuple
			Must contain hostname and port to use for connection
		credentials: tuple
			Must contain username and password for this connection
		queue: dict
			Must contain at least the following keys:
				queue: string - what queue to use
				passive: boolean - should we use an existing queue, to try to declare our own
			Options below are optional when passive = True
				durable: boolean - should the queue be durable
				auto_delete: boolean - should we auto delete the queue when we close the connection
		binds: list of dicts
			A list of dicts with the following keys:
				queue: string - name of the queue to bind
				exchange: string - name of the exchange to bind
				routing_key: string - routing key to use for this bind
		prefetch_count: int
			Define how many items may be prefetched at a time.
			The default value of 4 is a workaround of an issue that exists in python-pika 0.9.13. See
			the Github issue for more info: https://github.com/pika/pika/issues/286 .
		"""
		self.logger = logging.getLogger(__name__)

		self.logger.info("Creating AMQP connection to {0}:{1}".format(host[0], host[1]))
		self.credentials = pika.PlainCredentials(credentials[0], credentials[1])
		self.parameters = pika.ConnectionParameters(host=host[0], port=host[1], credentials=self.credentials)
		self.connection = pika.BlockingConnection(self.parameters)
		self.channel = self.connection.channel()
		self.channel.basic_qos(prefetch_count=4)

		self.queue_name = queue['queue']
		self.logger.info("Declaring queue {0}".format(self.queue_name))
		self.channel.queue_declare(**queue)

		if binds:
			self._perform_binds(binds)
def __init__ ( self , host , credentials , queue , binds = None , prefetch_count = 4 ) : self . logger = logging . getLogger ( __name__ ) self . logger . info ( "Creating AMQP connection to {0}:{1}" . format ( host [ 0 ] , host [ 1 ] ) ) self . credentials = pika . PlainCredentials ( credentials [ 0 ] , credentials [ 1 ] ) self . parameters = pika . ConnectionParameters ( host = host [ 0 ] , port = host [ 1 ] , credentials = self . credentials ) self . connection = pika . BlockingConnection ( self . parameters ) self . channel = self . connection . channel ( ) self . channel . basic_qos ( prefetch_count = 4 ) self . queue_name = queue [ 'queue' ] self . logger . info ( "Declaring queue {0}" . format ( self . queue_name ) ) self . channel . queue_declare ( ** queue ) if binds : self . _perform_binds ( binds )
Initialize AMQP connection.

		Parameters
		----------
		host: tuple
			Must contain hostname and port to use for connection
		credentials: tuple
			Must contain username and password for this connection
		queue: dict
			Must contain at least the following keys:
				queue: string - what queue to use
				passive: boolean - should we use an existing queue, to try to declare our own
			Options below are optional when passive = True
				durable: boolean - should the queue be durable
				auto_delete: boolean - should we auto delete the queue when we close the connection
		binds: list of dicts
			A list of dicts with the following keys:
				queue: string - name of the queue to bind
				exchange: string - name of the exchange to bind
				routing_key: string - routing key to use for this bind
		prefetch_count: int
			Define how many items may be prefetched at a time.
			The default value of 4 is a workaround of an issue that exists in python-pika 0.9.13. See
			the Github issue for more info: https://github.com/pika/pika/issues/286 .