modern-di integration for Celery
Project description
modern-di-celery
Modern-DI integration for Celery 5.x.
Quickstart
import typing
from celery import Celery
from modern_di import Container, Group, Scope, providers
from modern_di_celery import DITask, FromDI, setup_di
class Settings:
def __init__(self) -> None:
self.greeting = "hello"
class Dependencies(Group):
settings = providers.Factory(scope=Scope.APP, creator=Settings)
app = Celery("myapp", broker="redis://localhost", task_cls=DITask)
setup_di(app, Container(groups=[Dependencies], validate=True))
@app.task
def greet(name: str, settings: typing.Annotated[Settings, FromDI(Dependencies.settings)]) -> str:
return f"{settings.greeting}, {name}"
With task_cls=DITask every task is injected; alternatively decorate individual
tasks with @inject. See the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modern_di_celery-2.0.0.tar.gz.
File metadata
- Download URL: modern_di_celery-2.0.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d40320898c3708e8150e15c57d2007ef69d5b67415e239c134c080315a282812
|
|
| MD5 |
cce93329d4949b6713a55e4d7e665492
|
|
| BLAKE2b-256 |
15f147a804a08c2795690cec44a72f779edf0f3fa065407ed483753a4ad69bb9
|
File details
Details for the file modern_di_celery-2.0.0-py3-none-any.whl.
File metadata
- Download URL: modern_di_celery-2.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
589e54cb9aeda56853d8908c401219e9a27270b96f1d89c6c461239665af59da
|
|
| MD5 |
b67e365c39a908dfbc494031b4149aec
|
|
| BLAKE2b-256 |
7b0776ec25f193eac017b0313935da4f0f566891385579255222d97416961740
|