celery.contrib.batches

    警告

    For this to work you have to set CELERYD_PREFETCH_MULTIPLIER to zero, or some value where the final multiplied value is higher than flush_every.

    In the future we hope to add the ability to direct batching tasks to a channel with different QoS requirements than the task channel.

    Simple Example

    A click counter that flushes the buffer every 100 messages, and every seconds. Does not do anything with the data, but can easily be modified to store it in a database.

    Then you can ask for a click to be counted by doing:

    Example returning results

    An interface to the Web of Trust API that flushes the buffer every 100 messages, and every 10 seconds.

    Using the API is done as follows:

    注解

    If you don’t have an app instance then use the current app proxy instead:

    class celery.contrib.batches.Batches

    • Strategy(task, app, consumer)[源代码]

    • apply_buffer(requests, args=(), kwargs={})

    • flush(requests)[源代码]

    • flush_interval = 30

      Timeout in seconds before buffer is flushed anyway.

    • run(requests)

    class celery.contrib.batches.SimpleRequest(id, name, args, kwargs, delivery_info, hostname)[源代码]

    Pickleable request.

    • positional arguments

    • classmethod from_request(request)

    • hostname = None

      worker node name

    • id = None

      task id

    • name = None