{"id":27953824,"url":"https://github.com/glef1x/apscheduler-di","last_synced_at":"2025-10-14T18:12:34.628Z","repository":{"id":47130815,"uuid":"426561529","full_name":"GLEF1X/apscheduler-di","owner":"GLEF1X","description":"🧑🏻‍🔬 A lightweight and easy-to-use Dependency Injection plugin for APScheduler","archived":false,"fork":false,"pushed_at":"2024-12-09T02:00:55.000Z","size":162,"stargazers_count":18,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T17:14:56.756Z","etag":null,"topics":["apscheduler","asyncio","dependency-injection","scheduler","scheduler-library"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GLEF1X.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-10T09:32:06.000Z","updated_at":"2025-02-13T14:19:24.000Z","dependencies_parsed_at":"2024-12-09T03:18:28.263Z","dependency_job_id":"c7b491a4-a9d6-47c1-a6b0-7e16a6802c35","html_url":"https://github.com/GLEF1X/apscheduler-di","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLEF1X%2Fapscheduler-di","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLEF1X%2Fapscheduler-di/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLEF1X%2Fapscheduler-di/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GLEF1X%2Fapscheduler-di/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GLEF1X","download_url":"https://codeload.github.com/GLEF1X/apscheduler-di/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252922319,"owners_count":21825639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apscheduler","asyncio","dependency-injection","scheduler","scheduler-library"],"created_at":"2025-05-07T17:15:02.134Z","updated_at":"2025-10-14T18:12:29.609Z","avatar_url":"https://github.com/GLEF1X.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Implementation of dependency injection for `apscheduler`\n[![PyPI version](https://img.shields.io/pypi/v/apscheduler-di.svg)](https://pypi.org/project/apscheduler-di/)[![codecov](https://codecov.io/gh/GLEF1X/apscheduler-di/branch/master/graph/badge.svg?token=X71JFESNL5)](https://codecov.io/gh/GLEF1X/apscheduler-di)[![Downloads](https://pepy.tech/badge/apscheduler-di/week)](https://pepy.tech/project/apscheduler-di)\n\n### Motivation:\n\n* `apscheduler-di` addresses the issue of `apscheduler` not natively supporting Dependency Injection, making it challenging for developers to pass complex objects to jobs without encountering issues.\n\n## Features:\n\n* Supports type hints ([PEP 561](https://www.python.org/dev/peps/pep-0561/))\n* Extend `apscheduler` and provide handy aliases for events(such as `on_startup`, `on_shutdown` and\n  etc)\n* Offers a way to implement the [Dependency Inversion](https://en.wikipedia.org/wiki/Dependency_inversion_principle) principle from SOLID design principles.\n\n\"Under the hood\" `apscheduler-di`\nimplements [Decorator](https://en.wikipedia.org/wiki/Decorator_pattern) pattern and wraps up the\nwork of native `BaseScheduler` using [rodi](https://github.com/Neoteroi/rodi) lib\n\n### Quick example:\n\n```python\nimport os\nfrom typing import Dict\n\nfrom apscheduler.jobstores.redis import RedisJobStore\nfrom apscheduler.schedulers.blocking import BlockingScheduler\n\nfrom apscheduler_di import ContextSchedulerDecorator\n\n# pip install redis\njob_stores: Dict[str, RedisJobStore] = {\n    \"default\": RedisJobStore(\n        jobs_key=\"dispatched_trips_jobs\", run_times_key=\"dispatched_trips_running\"\n    )\n}\n\n\nclass Tack:\n\n    def tack(self):\n        print(\"Tack!\")\n\n\ndef tick(tack: Tack, some_argument: int):\n    print(tack)\n\n\ndef main():\n    scheduler = ContextSchedulerDecorator(BlockingScheduler(jobstores=job_stores))\n    scheduler.ctx.add_instance(Tack(), Tack)\n    scheduler.add_executor('processpool')\n    scheduler.add_job(tick, 'interval', seconds=3, kwargs={\"some_argument\": 5})\n    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))\n\n    try:\n        scheduler.start()\n    except (KeyboardInterrupt, SystemExit):\n        pass\n\n\nif __name__ == '__main__':\n    main()\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglef1x%2Fapscheduler-di","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglef1x%2Fapscheduler-di","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglef1x%2Fapscheduler-di/lists"}