Skip to content

Commit ad69123

Browse files
committed
fix(scheduler): preserve cancellation cleanup with send timeouts
2 parents 3c89db1 + 8a1b04d commit ad69123

57 files changed

Lines changed: 1310 additions & 826 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ permissions:
1717

1818
jobs:
1919
lint:
20-
strategy:
21-
matrix:
22-
cmd: ["black", "ruff", "mypy"]
2320
runs-on: ubuntu-latest
2421
steps:
2522
- uses: actions/checkout@v6
@@ -36,12 +33,11 @@ jobs:
3633
- name: Install deps
3734
run: uv sync --all-extras
3835
- name: Run lint check
39-
run: uv run pre-commit run -a ${{ matrix.cmd }}
36+
run: uv run prek run -a
4037
pytest:
4138
strategy:
4239
matrix:
4340
py_version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
44-
pydantic_ver: ["<2", ">=2.5,<3"]
4541
os: [ubuntu-latest, windows-latest, macos-latest]
4642
runs-on: "${{ matrix.os }}"
4743
steps:
@@ -60,8 +56,6 @@ jobs:
6056
version: "latest"
6157
- name: Install deps
6258
run: uv sync --all-extras
63-
- name: Setup pydantic version
64-
run: uv pip install "pydantic ${{ matrix.pydantic_ver }}"
6559
- name: Run pytest check
6660
run: uv run pytest -vv -n auto --cov="taskiq" .
6761
- name: Generate report

‎.pre-commit-config.yaml‎

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
31
repos:
42
- repo: https://github.com/pre-commit/pre-commit-hooks
53
rev: v6.0.0
64
hooks:
75
- id: check-ast
6+
7+
- repo: builtin
8+
hooks:
89
- id: trailing-whitespace
910
- id: check-toml
1011
- id: end-of-file-fixer
1112

12-
- repo: https://github.com/asottile/add-trailing-comma
13-
rev: v4.0.0
14-
hooks:
15-
- id: add-trailing-comma
16-
1713
- repo: https://github.com/crate-ci/typos
18-
rev: v1.38.1
14+
rev: v1.50.2
1915
hooks:
2016
- id: typos
2117

@@ -29,6 +25,12 @@ repos:
2925
'--exclude-lines', 'amqp://guest:guest@localhost:5672',
3026
]
3127

28+
- repo: https://github.com/astral-sh/ruff-pre-commit
29+
rev: v0.16.7
30+
hooks:
31+
- id: ruff-check
32+
args: [ "taskiq", "tests", "docs/examples" ]
33+
3234
- repo: local
3335
hooks:
3436
- id: black
@@ -37,19 +39,6 @@ repos:
3739
language: system
3840
types: [python]
3941

40-
- id: ruff
41-
name: Run ruff lints
42-
entry: uv run ruff
43-
language: system
44-
pass_filenames: false
45-
types: [python]
46-
args:
47-
- "check"
48-
- "--fix"
49-
- "taskiq"
50-
- "tests"
51-
- "docs/examples"
52-
5342
- id: mypy
5443
name: Validate types with MyPy
5544
entry: uv run mypy

‎docs/.vuepress/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineUserConfig({
3333
sidebar: "structure",
3434

3535
pure: true,
36+
focus: false,
3637

3738
markdown: {
3839
tabs: true,

‎docs/available-components/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dir:
66

77
# Available components
88

9-
In this section, you can find a list of officially supported plugins for the taskiq.
9+
In this section, you can find a list of officially supported plugins for taskiq.
1010

1111
- [Available brokers](./brokers.md)
1212
- [Available middlewares](./middlewares.md)

‎docs/available-components/brokers.md‎

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you choose this type of broker, please run taskiq with `-w 1` parameter,
2525
otherwise you may encounter undefined behavior.
2626
:::
2727

28-
To run this broker please install the [pyzmq](https://pypi.org/project/pyzmq/) lib. Or you can taskiq with `zmq` extra.
28+
To run this broker please install the [pyzmq](https://pypi.org/project/pyzmq/) lib. Or you can install taskiq with `zmq` extra.
2929

3030
::: tabs
3131

@@ -56,7 +56,7 @@ def my_task() -> bool:
5656
return True
5757
```
5858

59-
To kiq this task you have to options:
59+
To kiq this task you have two options:
6060

6161
- Explicitly define broker using kicker for this kiq;
6262
- Add default broker for all shared tasks.
@@ -82,8 +82,8 @@ await my_task.kicker().with_broker(broker).kiq()
8282

8383
## Custom brokers
8484

85-
These brokers are not parts of the core Taskiq lib. But they are maintained by Taskiq developers.
86-
You can install them as a separate packages.
85+
These brokers are not part of the core Taskiq lib. But they are maintained by Taskiq developers.
86+
You can install them as separate packages.
8787

8888
You can read more about parameters and abilities of these brokers in README.md of each repo.
8989

@@ -112,9 +112,25 @@ Project link: [taskiq-nats](https://github.com/taskiq-python/taskiq-nats).
112112
pip install taskiq-nats
113113
```
114114

115+
### SQS broker
116+
117+
Project link: [taskiq-sqs](https://github.com/taskiq-python/taskiq-sqs).
118+
119+
```bash
120+
pip install taskiq-sqs
121+
```
122+
123+
### Kafka broker
124+
125+
Project link: [taskiq-aio-kafka](https://github.com/taskiq-python/taskiq-aio-kafka).
126+
127+
```bash
128+
pip install taskiq-aio-kafka
129+
```
130+
115131
## Third-party brokers
116132

117-
These brokers are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
133+
These brokers are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.
118134

119135
You can read more about parameters and abilities of these brokers in README.md of each repo.
120136

@@ -141,3 +157,11 @@ Project link: [taskiq-ydb](https://github.com/danfimov/taskiq-ydb).
141157
```bash
142158
pip install taskiq-ydb
143159
```
160+
161+
### Azure Service Bus broker
162+
163+
Project link: [taskiq-service-bus](https://github.com/hamiltonkibbe/taskiq-service-bus).
164+
165+
```bash
166+
pip install taskiq-service-bus
167+
```

‎docs/available-components/result-backends.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This broker will always return `None` for any return_value. Please be careful.
2222

2323
## Official result backends
2424

25-
This result backends is not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.
25+
These result backends are not part of the core Taskiq library. But they are maintained by Taskiq developers. You can install them as a separate package.
2626

2727
### Redis result backend
2828

@@ -40,9 +40,17 @@ Project link: [taskiq-nats](https://github.com/taskiq-python/taskiq-nats).
4040
pip install taskiq-nats
4141
```
4242

43+
### S3 result backend
44+
45+
Project link: [taskiq-sqs](https://github.com/taskiq-python/taskiq-sqs). Provides `S3ResultBackend`.
46+
47+
```bash
48+
pip install taskiq-sqs
49+
```
50+
4351
## Third-party result backends
4452

45-
These result backends are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
53+
These result backends are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.
4654

4755
### PostgreSQL result backend
4856

‎docs/available-components/schedule-sources.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Parameters:
5656
- `cron` - crontab string when to run the task.
5757
- `cron_offset` - timezone offset for cron values. Explained [here](../guide/scheduling-tasks.md#working-with-timezones)
5858
- `interval` - Interval to run periodic tasks. Must be at least 1 second and cannot have fractional seconds.
59-
- `time` - specific time when send the task.
59+
- `time` - specific time when to send the task.
6060
- `args` - args to use, when invoking the task.
6161
- `kwargs` - key-word arguments to use when invoking the task.
6262
- `labels` - additional labels to use when invoking the task.
@@ -105,7 +105,7 @@ This schedule source doesn't use `schedule` label on tasks. To add new schedules
105105

106106
## Third-party schedule sources
107107

108-
These schedule sources are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as a separate packages.
108+
These schedule sources are not part of the core Taskiq library. They are maintained by other open‑source contributors. You can install them as separate packages.
109109

110110
### PostgreSQL schedule source
111111

‎docs/contrib.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ We have several rules for contributors:
99
* Please do not add malware.
1010
* Please make sure that your request solves the problem.
1111

12-
If you struggle with something or feel frustrated, you either create an issue, create a [discussions](https://github.com/orgs/taskiq-python/discussions).
12+
If you struggle with something or feel frustrated, you either create an issue, create a [discussions](https://github.com/orgs/taskiq-python/discussions)
1313
page or publish a draft PR and ask your question in the description.
1414

15-
We have lots of tests in CI. But since CI runs from first-time contributors should be approved, you better test locally. It just takes less time to prepare PR for merging.
15+
We have lots of tests in CI. But since CI runs from first-time contributors need to be approved, you better test locally. It just takes less time to prepare PR for merging.
1616

1717
## Setting up environment
1818

@@ -42,7 +42,7 @@ You can run `pytest` without any parameters and it will do the thing.
4242
pytest
4343
```
4444

45-
If you want to speedup testings, you can run it with `-n` option from [pytest-xdist](https://pypi.org/project/pytest-xdist/) to run tests in parallel.
45+
If you want to speed up testing, you can run it with `-n` option from [pytest-xdist](https://pypi.org/project/pytest-xdist/) to run tests in parallel.
4646

4747
```bash
4848
pytest -n 2
@@ -71,7 +71,7 @@ After that, you can run documentation server with hot-reloading using:
7171
pnpm docs:dev
7272
```
7373

74-
If you want to check how documentation looks like in production mode, you can build it and then serve using:
74+
If you want to check how documentation looks in production mode, you can build it and then serve using:
7575

7676
```bash
7777
pnpm docs:build
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import asyncio
2+
3+
from taskiq_dependencies import Depends
4+
5+
from taskiq.depends.progress_tracker import ProgressTracker, TaskState
6+
7+
8+
async def my_task(progress: ProgressTracker[str] = Depends()) -> None:
9+
for i in range(10):
10+
await asyncio.sleep(1)
11+
await progress.set_progress(TaskState.STARTED, meta=f"{(i + 1) * 10}%")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import asyncio
2+
from typing import Annotated
3+
4+
from taskiq_dependencies import Depends
5+
6+
from taskiq.depends.progress_tracker import ProgressTracker, TaskState
7+
8+
9+
async def my_task(progress: Annotated[ProgressTracker[str], Depends()]) -> None:
10+
for i in range(10):
11+
await asyncio.sleep(1)
12+
await progress.set_progress(TaskState.STARTED, meta=f"{(i + 1) * 10}%")

0 commit comments

Comments
 (0)