APScheduler integration for Dishka
This package provides integration of Dishka dependency injection framework and APScheduler, an advanced Python scheduler.
Installation
pip install apscheduler-dishka
Features
- automatic REQUEST scope management for scheduled jobs
- automatic injection of dependencies into job functions
- support for both sync and async schedulers
- support for
auto_injectmode to automatically wrap all jobs
How to use
- Import
from apscheduler_dishka import (
inject,
setup_dishka,
)
from dishka import make_container, Provider, provide, Scope, FromDishka
- Create provider
class YourProvider(Provider):
@provide(scope=Scope.REQUEST)
def create_interactor(self) -> Interactor:
...
- Mark those of your job function parameters which are to be injected with
FromDishka[]and decorate them using@inject
@inject
def job(
data: str,
interactor: FromDishka[Interactor],
):
...
- Create container
container = make_container(YourProvider())
- Setup
dishkaintegration
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler_dishka import setup_dishka
scheduler = BlockingScheduler()
setup_dishka(container=container, scheduler=scheduler)
- Add jobs to scheduler
scheduler.add_job(
job,
trigger="interval",
seconds=5,
args=["args"],
)
Auto-inject mode
If you don't want to manually decorate each job with @inject, you can use auto_inject mode:
setup_dishka(
container=container,
scheduler=scheduler,
auto_inject=True,
)
In this mode, all jobs will be automatically wrapped with dependency injection:
def job(
data: str,
interactor: FromDishka[Interactor],
):
...
scheduler.add_job(
job,
trigger="interval",
seconds=5,
args=["args"],
)
Async support
The library supports async schedulers:
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from dishka import make_async_container
from apscheduler_dishka import setup_dishka
scheduler = AsyncIOScheduler()
container = make_async_container(YourProvider())
setup_dishka(container=container, scheduler=scheduler)
Metadata
Release files for apscheduler-dishka 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apscheduler_dishka-1.1.1.tar.gz | 15.7 kB | Without provenance | Details for apscheduler_dishka-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apscheduler_dishka-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for apscheduler_dishka-1.1.1-py3-none-any.whl |
Total release size: 25.8 kB
Release files / apscheduler_dishka-1.1.1.tar.gz
| Download URL | apscheduler_dishka-1.1.1.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2daa1a8110a50afc1c3a59179e33225419f5e38019ca1711ef2e5b87bbe133e8
|
|
BLAKE2b-256 checksum How to use checksums |
dc1e72bc35bcc59104fc5d8386b3a4ac00c6f226992bd4dde7be81657038e766
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Release files / apscheduler_dishka-1.1.1-py3-none-any.whl
| Download URL | apscheduler_dishka-1.1.1-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fd9ff86a1faa09b924fc87e2c1d3206411a2acb31aee8310c40a9e8bb8f6435
|
|
BLAKE2b-256 checksum How to use checksums |
0cdf262afe2d65e69f6afff19f565c41fe1afb706db8a0201f95f84c2903b474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}
|
Security for apscheduler-dishka 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.