You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-3Lines changed: 70 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,16 @@
7
7
<hr/>
8
8
</div>
9
9
10
+
Documentation: https://taskiq-python.github.io/
11
+
12
+
## What is taskiq?
13
+
10
14
Taskiq is an asynchronous distributed task queue for python.
11
15
This project takes inspiration from big projects such as [Celery](https://docs.celeryq.dev) and [Dramatiq](https://dramatiq.io/).
12
-
But taskiq can send and run both the sync and async functions.
13
-
Also, we use [PEP-612](https://peps.python.org/pep-0612/) to provide the best autosuggestions possible. But since it's a new PEP, I encourage you to use taskiq with VS code because Pylance understands all types correctly.
16
+
But taskiq can send and run both the sync and async functions, has
17
+
integration with popular async frameworks, such as [FastAPI](https://fastapi.tiangolo.com/) and [AioHTTP](https://docs.aiohttp.org/en/stable/).
18
+
19
+
Also, we use [PEP-612](https://peps.python.org/pep-0612/) to provide the best autosuggestions possible. All code is type-hinted.
14
20
15
21
# Installation
16
22
@@ -25,8 +31,69 @@ Or it can be installed directly from git:
You can read more about how to use it in our docs: https://taskiq-python.github.io/.
34
+
# Usage
35
+
36
+
At first you need to create a broker. Broker is an object that can communicate to workers using distributed queues.
37
+
38
+
We have differet brokers for different queue backends. For example, we have a broker for [NATS](https://github.com/taskiq-python/taskiq-nats), [Redis](https://github.com/taskiq-python/taskiq-redis), [RabbitMQ](https://github.com/taskiq-python/taskiq-aio-pika), [Kafka](https://github.com/taskiq-python/taskiq-aio-kafka) and even more. Choose the one that fits you and create an instance.
The message is going to be sent to the broker and then to the worker. The worker will execute the function. To start worker processes, just run the following command:
76
+
77
+
```bash
78
+
taskiq worker path.to.the.module:broker
79
+
```
80
+
81
+
Where `path.to.the.module` is the path to the module where the broker is defined and `broker` is the name of the broker variable.
82
+
83
+
If you have tasks in different modules, you can ask taskiq to automatically import them by passing the `--fs-discover` flag:
It will import all modules called `tasks.py` in the current directory and all subdirectories.
90
+
91
+
Also, we support hot reload for workers. To enable it, just pass the `--reload` flag. It will reload the worker when the code changes (To use it, install taskiq with reload extra. E.g `pip install taskiq[reload]`).
92
+
93
+
94
+
Also, we have cool integrations with popular async frameworks. For example, we have an integration with [FastAPI](https://taskiq-python.github.io/framework_integrations/taskiq-with-fastapi.html) or [AioHTTP](https://taskiq-python.github.io/framework_integrations/taskiq-with-aiohttp.html). You can use it to reuse dependencies from your web app in your tasks.
29
95
96
+
Read about all features in our documentation: https://taskiq-python.github.io/
In this example, the task is defined using a lambda within the `main` function. As the lambda is not visible outside of the `main` function scope, the task is not executable by `taskiq worker` command.
19
19
@@ -24,10 +24,10 @@ To overcome this issue, you can:
24
24
25
25
Here's an example of a dynamic worker task creation:
In this example, a named dynamic lambda task is created and registered in a broker, similar to the previous example. The difference is the creation of a new receiver coroutine for the worker task. It will listen to the new messages and execute them. The worker task will be executed in the current event loop. After exiting the scope, the worker task will get cancelled. For illustration purposes it is cancelled explicitly.
30
30
31
31
It's possible to run a scheduler in the current event loop as well:
0 commit comments