Skip to content

Middleware now react on post-save hook. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Pavel Kirilin <win10@list.ru>"]

[tool.poetry.dependencies]
python = "^3.7"
taskiq = "^0"
taskiq = ">=0.0.8, <1"
typing-extensions = "^4.3.0"
pydantic = "^1.6.2"

Expand All @@ -22,7 +22,7 @@ isort = "^5.10.1"
yesqa = "^1.4.0"
wemake-python-styleguide = "^0.16.1"
mypy = "^0.971"
pytest-xdist = {version = "^2.5.0", extras = ["psutil"]}
pytest-xdist = { version = "^2.5.0", extras = ["psutil"] }

[tool.mypy]
strict = true
Expand Down
10 changes: 10 additions & 0 deletions taskiq_pipelines/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
"""Pipelines for taskiq tasks."""
from taskiq_pipelines.exceptions import AbortPipeline, PipelineError
from taskiq_pipelines.middleware import PipelineMiddleware
from taskiq_pipelines.pipeliner import Pipeline

__all__ = [
"Pipeline",
"PipelineError",
"AbortPipeline",
"PipelineMiddleware",
]
2 changes: 1 addition & 1 deletion taskiq_pipelines/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class PipelineMiddleware(TaskiqMiddleware):
"""Pipeline middleware."""

async def post_execute( # noqa: C901, WPS212
async def post_save( # noqa: C901, WPS212
self,
message: "TaskiqMessage",
result: "TaskiqResult[Any]",
Expand Down
4 changes: 2 additions & 2 deletions taskiq_pipelines/steps/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ async def filter_tasks( # noqa: C901, WPS210, WPS231
tasks_set.remove(task_id)
except LookupError:
continue
await asyncio.sleep(check_interval)
if tasks_set:
await asyncio.sleep(check_interval)

results = await context.broker.result_backend.get_result(parent_task_id)
filtered_results = []
Expand Down Expand Up @@ -135,7 +136,6 @@ async def act(
else:
task = await kicker.kiq(item, **self.additional_kwargs)
sub_task_ids.append(task.task_id)

await filter_tasks.kicker().with_task_id(task_id).with_broker(
broker,
).with_labels(
Expand Down
3 changes: 2 additions & 1 deletion taskiq_pipelines/steps/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ async def wait_tasks( # noqa: C901, WPS231
tasks_set.remove(task_id)
except LookupError:
continue
await asyncio.sleep(check_interval)
if tasks_set:
await asyncio.sleep(check_interval)

results = []
for task_id in ordered_ids: # noqa: WPS440
Expand Down