Implementation of dependency injection for apscheduler
Motivation:
apscheduler-disolves the problem sinceapschedulerdoesn't support Dependency Injection natively, and it's real problem for developers to pass on complicated objects to jobs without corruptions
Features:
- Supports type hints (PEP 561)
- Extend
apschedulerand provide handy aliases for events(such ason_startup,on_shutdownand etc) - Provide an opportunity to implement Dependency Inversion SOLID principle
"Under the hood" apscheduler-di just
implements Decorator pattern and wraps up the
work of native BaseScheduler using rodi lib
Quick example:
import os
from typing import Dict
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler_di import ContextSchedulerDecorator
# pip install redis
job_stores: Dict[str, RedisJobStore] = {
"default": RedisJobStore(
jobs_key="dispatched_trips_jobs", run_times_key="dispatched_trips_running"
)
}
class Tack:
def tack(self):
print("Tack!")
def tick(tack: Tack, some_argument: int):
print(tack)
def main():
scheduler = ContextSchedulerDecorator(BlockingScheduler(jobstores=job_stores))
scheduler.ctx.add_instance(Tack(), Tack)
scheduler.add_executor('processpool')
scheduler.add_job(tick, 'interval', seconds=3, kwargs={"some_argument": 5})
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
if __name__ == '__main__':
main()
Metadata
Release files for apscheduler-di 0.1.0
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 | |
|---|---|---|---|---|
| apscheduler_di-0.1.0.tar.gz | 8.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apscheduler_di-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / apscheduler_di-0.1.0.tar.gz
| Download URL | apscheduler_di-0.1.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc98b38a38829bc4974b3f0436e62bccd3c51989ad3e9646244110258b3e4f33
|
|
BLAKE2b-256 checksum How to use checksums |
da8a2422c8d892cee3968e69039a66f57ff915d021f7566b787fcc8b44816a03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/22.2.0
|
Release files / apscheduler_di-0.1.0-py3-none-any.whl
| Download URL | apscheduler_di-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aaeda49f4f9c5a4cdd3dcb9498e3431eecfedce50e05ccf77861cca70bfb44bc
|
|
BLAKE2b-256 checksum How to use checksums |
037bd39f91d965b4c18bc0baab9d202f9e3dbbb827ab33e5750fb650cd4e842b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/22.2.0
|
Security for apscheduler-di 0.1.0
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.