Beispiel #1
0
    def reset_connection(self):
        """Reset the AMQP connection, and reinitialize the
        :class:`carrot.messaging.ConsumerSet` instance.

        Resets the task consumer in :attr:`task_consumer`.

        """
        self.logger.debug(
                "CarrotListener: Re-establishing connection to the broker...")
        self.close_connection()
        self.amqp_connection = self._open_connection()
        self.task_consumer = get_consumer_set(connection=self.amqp_connection)
        self.task_consumer.register_callback(self.receive_message)
Beispiel #2
0
def discard_all(connection=None, connect_timeout=conf.BROKER_CONNECTION_TIMEOUT):
    """Discard all waiting tasks.

    This will ignore all tasks waiting for execution, and they will
    be deleted from the messaging server.

    :returns: the number of tasks discarded.

    """
    consumers = get_consumer_set(connection=connection)
    try:
        return consumers.discard_all()
    finally:
        consumers.close()
Beispiel #3
0
def discard_all(connection=None,
                connect_timeout=conf.BROKER_CONNECTION_TIMEOUT):
    """Discard all waiting tasks.

    This will ignore all tasks waiting for execution, and they will
    be deleted from the messaging server.

    :returns: the number of tasks discarded.

    """
    consumers = get_consumer_set(connection=connection)
    try:
        return consumers.discard_all()
    finally:
        consumers.close()
Beispiel #4
0
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
Beispiel #6
0
 def _setup_consumer(self):
     self.connection = establish_connection()
     self.consumer = get_consumer_set(self.connection)