|
@@ -1,4 +1,4 @@
|
|
|
-# Distributed Architecture
|
|
|
+# Redis-Celery (Distributed Architecture)
|
|
|
|
|
|
This includes
|
|
|
* Redis
|
|
@@ -6,6 +6,10 @@ This includes
|
|
|
|
|
|
|
|
|
## Celery
|
|
|
+[Celery Documentation](https://docs.celeryq.dev/en/stable/index.html)
|
|
|
+[Flower Documentation](https://flower.readthedocs.io/en/latest/auth.html)
|
|
|
+### install "celery"
|
|
|
+``` pip install -U "celery[redis]" ```
|
|
|
### Starting the worker
|
|
|
```shell
|
|
|
celery -A proj worker
|
|
@@ -31,4 +35,25 @@ Pool Options:
|
|
|
available on your system.
|
|
|
``` celery worker --help ``` can get more infomation.
|
|
|
### woker in Windows
|
|
|
-add ``` --pool=solo ``` option
|
|
|
+add ``` --pool=solo ``` option
|
|
|
+
|
|
|
+### Calling the task
|
|
|
+```shell
|
|
|
+>>> from tasks import add
|
|
|
+>>> add.hello()
|
|
|
+```
|
|
|
+If your celery app set rsult backend
|
|
|
+```
|
|
|
+>>> from tasks import add
|
|
|
+>>> result = add.hello()
|
|
|
+```
|
|
|
+The ready() method returns whether the task has finished processing or not:
|
|
|
+```
|
|
|
+>>> result.ready()
|
|
|
+>>> False
|
|
|
+```
|
|
|
+You can wait for the result to complete, but this is rarely used since it turns the asynchronous call into a synchronous one:
|
|
|
+```
|
|
|
+>>> result.get(timeout=1)
|
|
|
+>>> 'hello world'
|
|
|
+```
|