mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-27 00:58:11 +08:00
docs: some formatting updates and minor fixes
This commit is contained in:
+20
-20
@@ -41,15 +41,15 @@ The function to call after the task has been executed. This function gets passed
|
||||
|
||||
group
|
||||
"""""
|
||||
A group label. Check :ref:`groups` for group functions
|
||||
A group label. Check :ref:`groups` for group functions.
|
||||
|
||||
save
|
||||
""""
|
||||
Overrides the result backend's save setting.
|
||||
Overrides the result backend's save setting for this task.
|
||||
|
||||
timeout
|
||||
"""""""
|
||||
Overrides the cluster's timeout setting.
|
||||
Overrides the cluster's timeout setting for this task.
|
||||
|
||||
sync
|
||||
""""
|
||||
@@ -61,7 +61,7 @@ A redis connection. In case you want to control your own connections.
|
||||
|
||||
q_options
|
||||
"""""""""
|
||||
None of the option keywords get passed on to the function.
|
||||
None of the option keywords get passed on to the task function.
|
||||
As an alternative you can also put them in
|
||||
a single keyword dict named ``q_options``. This enables you to use these keywords for your function call::
|
||||
|
||||
@@ -79,7 +79,7 @@ Please not that this will override any other option keywords.
|
||||
|
||||
Groups
|
||||
------
|
||||
You can group together results by passing :func:`async` the optional `group` keyword:
|
||||
You can group together results by passing :func:`async` the optional ``group`` keyword:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -111,7 +111,7 @@ Instead of :func:`result_group` you can also use :func:`fetch_group` to return a
|
||||
# only use the successes
|
||||
results = fetch_group('modf')
|
||||
if failure_count:
|
||||
results.exclude(success=False)
|
||||
results = results.exclude(success=False)
|
||||
results = [task.result for task in successes]
|
||||
|
||||
# this is the same as
|
||||
@@ -126,13 +126,13 @@ Getting results by using :func:`result_group` is of course much faster than usin
|
||||
|
||||
.. note::
|
||||
|
||||
Although :func:`fetch_group` returns a queryset, due to the nature of the PickleField , calling `Queryset.values` on it will return a list of encoded results.
|
||||
Although :func:`fetch_group` returns a queryset, due to the nature of the PickleField , calling ``Queryset.values`` on it will return a list of encoded results.
|
||||
Use list comprehension or an iterator instead.
|
||||
|
||||
Synchronous testing
|
||||
-------------------
|
||||
|
||||
:func:`async` can be instructed to execute a task immediately by setting the optional keyword `sync=True`.
|
||||
:func:`async` can be instructed to execute a task immediately by setting the optional keyword ``sync=True``.
|
||||
The task will then be injected straight into a worker and the result saved by a monitor instance::
|
||||
|
||||
from django_q import async, fetch
|
||||
@@ -157,7 +157,7 @@ Connection pooling
|
||||
------------------
|
||||
|
||||
Django Q tries to pass redis connections around its parts as much as possible to save you from running out of connections.
|
||||
When you are making individual calls to :func:`async` a lot though, it can help to set up a redis connection to pass to :func:`async`:
|
||||
When you are making individual calls to :func:`async` a lot though, it can help to set up a redis connection to reuse for :func:`async`:
|
||||
|
||||
.. code:: python
|
||||
|
||||
@@ -217,7 +217,7 @@ Reference
|
||||
Returns the results of a task group
|
||||
|
||||
:param str group_id: the group identifier
|
||||
:param bool failures: set this to `True` to include failed results
|
||||
:param bool failures: set this to ``True`` to include failed results
|
||||
:returns: a list of results
|
||||
:rtype: list
|
||||
|
||||
@@ -226,7 +226,7 @@ Reference
|
||||
Returns a list of tasks in a group
|
||||
|
||||
:param str group_id: the group identifier
|
||||
:param bool failures: set this to `False` to exclude failed tasks
|
||||
:param bool failures: set this to ``False`` to exclude failed tasks
|
||||
:returns: a list of Tasks
|
||||
:rtype: list
|
||||
|
||||
@@ -235,7 +235,7 @@ Reference
|
||||
Counts the number of task results in a group.
|
||||
|
||||
:param str group_id: the group identifier
|
||||
:param bool failures: counts the number of failures if `True`
|
||||
:param bool failures: counts the number of failures if ``True``
|
||||
:returns: the number of tasks or failures in a group
|
||||
:rtype: int
|
||||
|
||||
@@ -244,7 +244,7 @@ Reference
|
||||
Deletes a group label from the database.
|
||||
|
||||
:param str group_id: the group identifier
|
||||
:param bool tasks: also deletes the associated tasks if `True`
|
||||
:param bool tasks: also deletes the associated tasks if ``True``
|
||||
:returns: the numbers of tasks affected
|
||||
:rtype: int
|
||||
|
||||
@@ -263,7 +263,7 @@ Reference
|
||||
.. note::
|
||||
|
||||
This is for convenience and can be used as a parameter for most functions that take a `task_id`.
|
||||
Keep in mind however that it is not guaranteed to be unique if you store very large amounts of tasks in the database.
|
||||
Keep in mind that it is not guaranteed to be unique if you store very large amounts of tasks in the database.
|
||||
|
||||
.. py:attribute:: func
|
||||
|
||||
@@ -314,7 +314,7 @@ Reference
|
||||
.. py:classmethod:: get_result_group(group_id, failures=False)
|
||||
|
||||
Returns a list of results from a task group.
|
||||
Set failures to `True` to include failed results.
|
||||
Set failures to ``True`` to include failed results.
|
||||
|
||||
.. py:classmethod:: get_task(task_id)
|
||||
|
||||
@@ -323,22 +323,22 @@ Reference
|
||||
.. py:classmethod:: get_task_group(group_id, failures=True)
|
||||
|
||||
Gets a queryset of tasks with this group id.
|
||||
Set failures to `False` to exclude failed tasks.
|
||||
Set failures to ``False`` to exclude failed tasks.
|
||||
|
||||
.. py:classmethod:: get_group_count(group_id, failures=False)
|
||||
|
||||
Returns a count of the number of tasks results in a group.
|
||||
Returns the number of failures when `failures=True`
|
||||
Returns the number of failures when ``failures=True``
|
||||
|
||||
.. py:classmethod:: delete_group(group_id, objects=False)
|
||||
|
||||
Deletes a group label only, by default.
|
||||
If `objects=True` it will also delete the tasks in this group from the database.
|
||||
If ``objects=True`` it will also delete the tasks in this group from the database.
|
||||
|
||||
.. py:class:: Success
|
||||
|
||||
A proxy model of :class:`Task` with the queryset filtered on :attr:`Task.success` is True.
|
||||
A proxy model of :class:`Task` with the queryset filtered on :attr:`Task.success` is ``True``.
|
||||
|
||||
.. py:class:: Failure
|
||||
|
||||
A proxy model of :class:`Task` with the queryset filtered on :attr:`Task.success` is False.
|
||||
A proxy model of :class:`Task` with the queryset filtered on :attr:`Task.success` is ``False``.
|
||||
Reference in New Issue
Block a user