Tryton provides a way to run asynchronously some tasks. You must activate the
worker in the
queue section of the configuration and run the worker manager otherwise the tasks will be run at the end of the
A task is the parameters that defines how to call a method from a
This include the
user and the arguments.
The first argument of the method must be an instance or a list of instances of
This other arguments must be JSON-ifiable.
A task is pushed into the
queue by calling the desired method on the
This stores in the queue all the current parameters of the call and it will be
execute by a worker or at the end of the transaction if no worker is
context keys are used as
parameters for the queue:
The name of the queue. Default value is
datetime.timedeltato add to current time to define when the task should be started. Default value is
Nonewhich means directly.
datetime.timedeltato add to current time to define when the task should be finished. Default value is
Nonewhich means as soon as possible.
integerto divide the instances by batch of this size. If the value is
truethen the size is the value defined by the configuration
batch_size. Default is
Nonewhich means no division.
There is no access right verification during the execution of the task.
from trytond.model import Model
__name__ = 'my_model'
def launch(cls, records):
for record in records:
def process(self, value):
self.value = value