mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-02 21:38:13 +08:00
Replaces async occurrences with alternatives
* async is now a reserved word in python3.7 * Rename async function to enqueue * Rename all async_ functions to enqueue_ * Rename Async class to AsyncTask * Updates the docs.
This commit is contained in:
+11
-11
@@ -2,17 +2,17 @@
|
||||
|
||||
Chains
|
||||
======
|
||||
Sometimes you want to run tasks sequentially. For that you can use the :func:`async_chain` function:
|
||||
Sometimes you want to run tasks sequentially. For that you can use the :func:`enqueue_chain` function:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Async a chain of tasks
|
||||
from django_q.tasks import async_chain, result_group
|
||||
# enqueue a chain of tasks
|
||||
from django_q.tasks import enqueue_chain, result_group
|
||||
|
||||
# the chain must be in the format
|
||||
# [(func,(args),{kwargs}),(func,(args),{kwargs}),..]
|
||||
group_id = async_chain([('math.copysign', (1, -1)),
|
||||
('math.floor', (1,))])
|
||||
group_id = enqueue_chain([('math.copysign', (1, -1)),
|
||||
('math.floor', (1,))])
|
||||
|
||||
# get group result
|
||||
result_group(group_id, count=2)
|
||||
@@ -21,7 +21,7 @@ A slightly more convenient way is to use a :class:`Chain` instance:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Chain async
|
||||
# Chain enqueue
|
||||
from django_q.tasks import Chain
|
||||
|
||||
# create a chain that uses the cache backend
|
||||
@@ -41,9 +41,9 @@ A slightly more convenient way is to use a :class:`Chain` instance:
|
||||
|
||||
Reference
|
||||
---------
|
||||
.. py:function:: async_chain(chain, group=None, cached=Conf.CACHED, sync=Conf.SYNC, broker=None)
|
||||
.. py:function:: enqueue_chain(chain, group=None, cached=Conf.CACHED, sync=Conf.SYNC, broker=None)
|
||||
|
||||
Async a chain of tasks. See also the :class:`Chain` class.
|
||||
enqueue a chain of tasks. See also the :class:`Chain` class.
|
||||
|
||||
:param list chain: a list of tasks in the format [(func,(args),{kwargs}), (func,(args),{kwargs})]
|
||||
:param str group: an optional group name.
|
||||
@@ -52,7 +52,7 @@ Reference
|
||||
|
||||
.. py:class:: Chain(chain=None, group=None, cached=Conf.CACHED, sync=Conf.SYNC)
|
||||
|
||||
A sequential chain of tasks. Acts as a convenient wrapper for :func:`async_chain`
|
||||
A sequential chain of tasks. Acts as a convenient wrapper for :func:`enqueue_chain`
|
||||
You can pass the task chain at construction or you can append individual tasks before running them.
|
||||
|
||||
:param list chain: a list of task in the format [(func,(args),{kwargs}), (func,(args),{kwargs})]
|
||||
@@ -63,7 +63,7 @@ Reference
|
||||
|
||||
.. py:method:: append(func, *args, **kwargs)
|
||||
|
||||
Append a task to the chain. Takes the same arguments as :func:`async`
|
||||
Append a task to the chain. Takes the same arguments as :func:`enqueue`
|
||||
|
||||
:return: the current number of tasks in the chain
|
||||
:rtype: int
|
||||
@@ -102,4 +102,4 @@ Reference
|
||||
|
||||
get the length of the chain
|
||||
|
||||
:return int: length of the chain
|
||||
:return int: length of the chain
|
||||
|
||||
Reference in New Issue
Block a user