mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-24 13:48:12 +08:00
docs: some tweaks on the new functions
This commit is contained in:
+4
-3
@@ -179,6 +179,8 @@ here's an example of how you can have Django Q take care of your indexes in real
|
||||
Now every time a Document is saved, your indexes will be updated without causing a delay in your save action.
|
||||
You could expand this to dealing with deletes, by adding a ``post_delete`` signal and calling ``index.remove_object`` in the async function.
|
||||
|
||||
.. _shell:
|
||||
|
||||
Shell
|
||||
=====
|
||||
You can execute or schedule shell commands using Pythons :mod:`subprocess` module:
|
||||
@@ -267,7 +269,7 @@ Adapted from `Sebastian Raschka's blog <http://sebastianraschka.com/Articles/201
|
||||
k_n += 1
|
||||
return h, (k_n / len(x_samples)) / (h ** point_x.shape[1])
|
||||
|
||||
# create 100 calculations and send them to the cluster
|
||||
# create 100 calculations and return the collated result
|
||||
def parzen_async():
|
||||
# clear the previous results
|
||||
delete_group('parzen', cached=True)
|
||||
@@ -292,8 +294,7 @@ Alternatively the ``parzen_async()`` function can also be written with :func:`as
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# create 100 calculations and send them to the cluster
|
||||
# with async_iter
|
||||
# create 100 calculations and return the collated result
|
||||
def parzen_async():
|
||||
mu_vec = numpy.array([0, 0])
|
||||
cov_mat = numpy.array([[1, 0], [0, 1]])
|
||||
|
||||
@@ -85,6 +85,7 @@ Or you can make a wrapper function which you can then schedule in Django Q:
|
||||
schedule('tasks.clear_sessions_command', schedule_type='H')
|
||||
|
||||
|
||||
Check out the :ref:`shell` examples if you want to schedule regular shell commands
|
||||
|
||||
Reference
|
||||
---------
|
||||
|
||||
+3
-3
@@ -187,7 +187,7 @@ By using a cache backend like Redis or Memcached you can speed up access to your
|
||||
|
||||
When you set ``cached=True``, results will be saved permanently in the cache and you will have to rely on your backend's cleanup strategies (like LRU) to
|
||||
manage stale results.
|
||||
You can also opt to set a manual timeout on the results, by setting ``cached=60``. Meaning the result will be evicted from the cache after 60 seconds.
|
||||
You can also opt to set a manual timeout on the results, by setting e.g. ``cached=60``. Meaning the result will be evicted from the cache after 60 seconds.
|
||||
This works both globally or on individual async executions.::
|
||||
|
||||
# simple cached example
|
||||
@@ -199,8 +199,8 @@ This works both globally or on individual async executions.::
|
||||
# wait max 50ms for the result to appear in the cache
|
||||
result(id, wait=50, cached=True)
|
||||
|
||||
# o fetch the task object
|
||||
task = fetch(id, cache=True)
|
||||
# or fetch the task object
|
||||
task = fetch(id, cached=True)
|
||||
|
||||
# and then save it to the database
|
||||
task.save()
|
||||
|
||||
Reference in New Issue
Block a user