Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 4
0
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
Ejemplo n.º 5
0
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
Ejemplo n.º 6
0
Archivo: jobs.py Proyecto: spsu/sylph
 def _setup_consumer(self):
     self.connection = establish_connection()
     self.consumer = get_consumer_set(self.connection)