https://github.com/digitalmethodsinitiative/dmi-scheduler
A lightweight job queue & scheduler
https://github.com/digitalmethodsinitiative/dmi-scheduler
Last synced: 5 months ago
JSON representation
A lightweight job queue & scheduler
- Host: GitHub
- URL: https://github.com/digitalmethodsinitiative/dmi-scheduler
- Owner: digitalmethodsinitiative
- License: mit
- Created: 2020-07-15T12:50:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-05-27T12:51:59.000Z (about 1 year ago)
- Last Synced: 2025-10-26T04:55:27.728Z (7 months ago)
- Language: Python
- Size: 62.5 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dmi-scheduler
A lightweight task scheduler in Python.
## Installation
```
pip3 install dmi-scheduler
```
PostgreSQL is used to keep track of jobs. As such, you need to have a
PostgreSQL database that the scheduler can interact with. Database
tables will be created automatically if they don't exist yet. You can
pass the database connection parameters to the `Scheduler()`
constructor with the `dbname`, `dbhost`, `dbuser`, `dbpassword` and
`dbport` keyword arguments.
## Example
```
import time
from dmi_scheduler.scheduler import Scheduler
scheduler = Scheduler(config="scheduler.yml")
for i in range(0, 100):
scheduler.queue.add_job("log_number.py")
while scheduler.has_jobs():
time.sleep(1)
scheduler.end()
print("Done! Results can be found in the log file.")
```
`log_number.py`:
```
from random import choice
from dmi_scheduler.worker import BasicWorker
class SomeWorker(BasicWorker):
max_workers = 3
def work(self):
self.log.info("Here is a random number: %i" % choice(range(0,1000)))
```
## License
This scraper was developed by the
[Digital Methods Initiative](https://digitalmethods.net), and is distributed
under the MIT license. See LICENSE for details.