dispatch
Python package for timed dispatching of events or work
Usage
### The Reactor ###
from dispatch import Reactor
r = Reactor()
# The dispatch function needs two parameters, a schedule and an action
schedule = r.schedule_interval(seconds=2) # Run every 2 seconds
action = r.action(print, "hello") # Call the print function with the parameter "hello"
r.dispatch(schedule, action)
r.run()
### The Actions ###
# There are two helper functions that build actions based on functions:
r.action(func, parameter, parameter2, kwarg1=value) # Runs in main loop
r.background_action(func, parameter, parameter2, kwarg1=value) # Runs in new thread
### The Schedules ###
# A schedule is just an iterator that returns timestamps but there are
# several constructors included which make needing to write one rare
from datetime import datetime
# Run once on April 1st 2012 at 4 am
r.schedule_one_time(datetime(2020,4,1,4))
# Run on August 5th and 8th, 2020
timestamps = [datetime(2020, 8, 1), datetime(2020, 8, 5)]
schedule = iter(timestamps)
# To run at 8am and 5pm on Tuesdays and thursdays
r.schedule_calendar(days_of_week=["Tuesday", "Thursday"], hours=[8, 17])
# To run hourly on the 15th minute
r.schedule_hourly(minute=15)
# To run daily at 5:12 pm
r.schedule_daily(hour=17, minute=12)
# To run every hour and a half
r.schedule_interval(hours=1, minutes=30)
# To run every 26 hours till the year 2020
r.schedule_interval(days=1 hours=2, till=datetime(2020, 1, 1))
# To run on the 1st 5th, 10th, 15th, 20th, and 25th of the month @ midnight
r.schedule_calendar(days=[1,5,10,15,20,25])
# To run mondays on every hour
r.schedule_calendar(days_of_week=['Monday'], hours='*')
Metadata
Release files for dispatch-reactor 2.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 | |
|---|---|---|---|---|
| dispatch_reactor-2.1.1.tar.gz | 8.0 kB | Without provenance | Details |
Release files / dispatch_reactor-2.1.1.tar.gz
| Download URL | dispatch_reactor-2.1.1.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb5bb8bb2aea4a3eb8f2c883968732e3ec877e2b443fb556bccf6caa6bbfc657
|
|
BLAKE2b-256 checksum How to use checksums |
9aa7b8d946ab2b4369f552a2aa33c8f9314c0046af1e77c62917bf3f2d645f5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
|
Security for dispatch-reactor 2.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.