예제 #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)
예제 #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()
예제 #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()
예제 #4
0
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
예제 #5
0
 def test_get_consume_set(self):
     conn = messaging.establish_connection()
     messaging.get_consumer_set(conn).close()
     conn.close()
예제 #6
0
파일: jobs.py 프로젝트: spsu/sylph
 def _setup_consumer(self):
     self.connection = establish_connection()
     self.consumer = get_consumer_set(self.connection)