Skip to content

Commit a05bb3b

Browse files
authored
Added depdencies override as in fastapi. (#228)
1 parent dd0758d commit a05bb3b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typing-extensions = ">=3.10.0.0"
3131
pydantic = ">=1.0,<=3.0"
3232
importlib-metadata = "*"
3333
pycron = "^3.0.0"
34-
taskiq_dependencies = "^1"
34+
taskiq_dependencies = ">=1.3.1,<2"
3535
anyio = ">=3"
3636
packaging = ">=19"
3737
# For prometheus metrics

taskiq/abc/broker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def __init__(
112112
] = defaultdict(list)
113113
self.state = TaskiqState()
114114
self.custom_dependency_context: Dict[Any, Any] = {}
115+
self.dependency_overrides: Dict[Any, Any] = {}
115116
# True only if broker runs in worker process.
116117
self.is_worker_process: bool = False
117118
# True only if broker runs in scheduler process.

taskiq/receiver/receiver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ async def run_task( # noqa: C901, PLR0912, PLR0915
207207
TaskiqState: self.broker.state,
208208
},
209209
)
210-
dep_ctx = dependency_graph.async_ctx(broker_ctx)
210+
dep_ctx = dependency_graph.async_ctx(
211+
broker_ctx,
212+
self.broker.dependency_overrides or None,
213+
)
211214
# Resolve all function's dependencies.
212215

213216
# Start a timer.

0 commit comments

Comments
 (0)