Always-on event scheduler
Project description
Event Scheduler
Table of Contents
Overview
The Event Scheduler uses an internal thread to allow the application to schedule events to occur either ASAP or at a specified time in the future. Instead of blocking your application's main thread, you can concurrently run some lightweight tasks. We took some inspiration for the API design from the python library's scheduler. Unlike the native sched module, the Event Scheduler is always on and ready to accept events. Event Scheduler is completely thread-safe too!
Installing
You should already have pip installed if you're using python > 3.4. If you don't, please visit this link to install it.
To install event scheduler, type the following command in the terminal:
pip install event-scheduler
To import the module, add the following lines in your Python file.
from event_scheduler import EventScheduler
To download directly visit PyPi or the GitHub repository.
Documentation
Full documentation can be found here.
Quick Start
event_scheduler.start()
Enable the event scheduler to start taking events
event_scheduler.stop(hard_stop=False)
Stop the event scheduler and its internal thread. Set
hard_stop
toTrue
to stop the scheduler right away and discard all pending events. Sethard_stop
toFalse
to wait for all events to finish executing at their scheduled times.
event_scheduler.enter(delay, priority, action, arguments=(), kwargs={})
Schedule an event with a callable
action
to be executed after thedelay
. Events will be executed according to theirdelay
andpriority
(lower number = higher priority).arguments
holds positional arguments andkwargs
hold keyword arguments for the action. Returns an event object which can be used to cancel the event.
event_scheduler.cancel(event)
Cancel the event if it has not yet been executed.
event_scheduler.cancel_recurring(event_id)
Cancel the recurring event and all future occurrences.
from event_scheduler import EventScheduler
event_scheduler = EventScheduler()
# Starts the scheduler
event_scheduler.start()
# Schedule an event that prints a message after 5 seconds
event_scheduler.enter(5, 0, print, ('5 seconds has passed since this event was entered!',))
# Schedule a recurring event that prints a message every 10 seconds
event_scheduler.enter_recurring(10, 0, print, ('10 second interval has passed!',))
Output:
5 seconds has passed since this event was entered!
10 second interval has passed!
10 second interval has passed!
...
Example
Please refer here for the example.
Contact
Please email phluentmed@gmail.com or open an issue if you need any help using the module, have any questions, or even have some feature suggestions.
Recommended Email format:
Subject: EventScheduler - [Issue]
Steps to reproduce: (Please include code snippets or stack trace where possible)
Device used:
Platform:
Actual result:
Expected result:
Comments:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file event-scheduler-0.1.3.tar.gz
.
File metadata
- Download URL: event-scheduler-0.1.3.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96d5b16ff23bc9df5f65d27e68c700d800fc78b4ec89ab7feb63bc940ab989d5 |
|
MD5 | 901c7a3b8b6eca9ab7bd18cbe7f95fc5 |
|
BLAKE2b-256 | ea12a78f551a8d434d30044fb5fc21cbe65a0451854c5293dec39b44dd59d7d1 |
File details
Details for the file event_scheduler-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: event_scheduler-0.1.3-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a7f7da153badb9ac58e692e6448c86876dcf251fe1962f71ec864eba43366c |
|
MD5 | 0b16fbadceffaa24aa7b672e1a5c689b |
|
BLAKE2b-256 | cd4743abbf321ceb61aad8e61800c29c708b2ef7bebe68513743bba40ae560b7 |