modern-di integration for arq
Project description
modern-di-arq
Modern-DI integration for arq.
Install
pip install modern-di-arq
Quickstart
import typing
from modern_di import Container, Group, Scope, providers
from modern_di_arq import FromDI, inject, setup_di
class Settings:
def __init__(self) -> None:
self.greeting = "hello"
class Dependencies(Group):
settings = providers.Factory(scope=Scope.APP, creator=Settings)
@inject
async def greet(ctx: dict, name: str, settings: typing.Annotated[Settings, FromDI(Dependencies.settings)]) -> str:
return f"{settings.greeting}, {name}"
class WorkerSettings:
functions = [greet]
setup_di(WorkerSettings, Container(groups=[Dependencies], validate=True))
setup_di wires the root container's lifecycle to arq's on_startup/on_shutdown
and seeds it into arq's ctx dict; a per-job Scope.REQUEST child is built in
on_job_start and closed in on_job_end. Decorate individual tasks with
@inject to resolve FromDI markers from that child. 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_arq-2.0.0.tar.gz.
File metadata
- Download URL: modern_di_arq-2.0.0.tar.gz
- Upload date:
- Size: 4.4 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 |
3cf430ff1635ddd8bea71c6035343bdf0f971651e4454ec0946fb8c59f7a6ab5
|
|
| MD5 |
1ef5b1660ab9ffe4a5292cd48a178d58
|
|
| BLAKE2b-256 |
732c4a8b31fee604e07957b82eded60728238740e42c92db9a5d66be0e9b51d7
|
File details
Details for the file modern_di_arq-2.0.0-py3-none-any.whl.
File metadata
- Download URL: modern_di_arq-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.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 |
6fe192e27ff154de116a215055bacacb26fdac7786de0eb4dbbbe4b8e7ea752c
|
|
| MD5 |
1f00d052f7415f1e623de61d36f700eb
|
|
| BLAKE2b-256 |
e92cb3cf1e904771dc9133e8b2c94fedfec856f62398f5fc523c74d4a5e2d0db
|