mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 04:48:12 +08:00
docs: minor tweaks to cached group example
This commit is contained in:
+4
-4
@@ -296,7 +296,7 @@ Alternatively the ``parzen_async()`` function can also be written with :func:`as
|
|||||||
|
|
||||||
# create 100 calculations and return the collated result
|
# create 100 calculations and return the collated result
|
||||||
def parzen_async():
|
def parzen_async():
|
||||||
mu_vec = numpy.array([0, 0])
|
mu_vec = numpy.array([0, 0])n this case, but without hook support.
|
||||||
cov_mat = numpy.array([[1, 0], [0, 1]])
|
cov_mat = numpy.array([[1, 0], [0, 1]])
|
||||||
sample = numpy.random. \
|
sample = numpy.random. \
|
||||||
multivariate_normal(mu_vec, cov_mat, 10000)
|
multivariate_normal(mu_vec, cov_mat, 10000)
|
||||||
@@ -304,9 +304,9 @@ Alternatively the ``parzen_async()`` function can also be written with :func:`as
|
|||||||
x = numpy.array([[0], [0]])
|
x = numpy.array([[0], [0]])
|
||||||
# async them with async iterable
|
# async them with async iterable
|
||||||
args = [(sample, x, w) for w in widths]
|
args = [(sample, x, w) for w in widths]
|
||||||
result_id = async_iter(parzen_estimation, args)
|
result_id = async_iter(parzen_estimation, args, cached=True)
|
||||||
# return the result or timeout after 10 seconds
|
# return the cached result or timeout after 10 seconds
|
||||||
return result(result_id, wait=10000)
|
return result(result_id, wait=10000, cached=True)
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|||||||
+3
-1
@@ -205,6 +205,8 @@ This works both globally or on individual async executions.::
|
|||||||
# and then save it to the database
|
# and then save it to the database
|
||||||
task.save()
|
task.save()
|
||||||
|
|
||||||
|
As you can see you can easily turn a cached result into a permanent database result by calling ``save()`` on it.
|
||||||
|
|
||||||
This also works for group actions::
|
This also works for group actions::
|
||||||
|
|
||||||
# cached group example
|
# cached group example
|
||||||
@@ -225,7 +227,7 @@ This also works for group actions::
|
|||||||
# wait max 50ms for one hundred results to return
|
# wait max 50ms for one hundred results to return
|
||||||
result_group('frexp', wait=50, count=100, cached=True)
|
result_group('frexp', wait=50, count=100, cached=True)
|
||||||
|
|
||||||
Note that exact same result can be achieved by using the more convenient :func:`async_iter` in this case, but without hook support.
|
If you don't need hooks, that exact same result can be achieved by using the more convenient :func:`async_iter`.
|
||||||
|
|
||||||
Synchronous testing
|
Synchronous testing
|
||||||
-------------------
|
-------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user