EventScheduler Package
Table of Contents
Overview
Phluent's always on event scheduler is a modified version of the native python library's scheduler. This means the event scheduler will always be running even with no actions. With python's sched module, a call to run() has to be made every time the number of pending events reaches zero and new events are added. With EventScheduler, only one call to start() needs to be made to start the event scheduler and it's ready to accept and run actions even when empty.
Refer to sched.scheduler for the descriptions of the non-modified functions.
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 the always-on 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.
Features
Previous features:
scheduler.enterabs(time, priority, action, argument=(), kwargs={})
Schedule a new event. The time argument should be a numeric type compatible with the return value of the timefunc function passed to the constructor. Events scheduled for the same time will be executed in the order of their priority. A lower number represents a higher priority.
Executing the event means executing action(*argument, **kwargs). argument is a sequence holding the positional arguments for action. kwargs is a dictionary holding the keyword arguments for action.
Return value is an event which may be used for later cancellation of the event (see cancel()).
scheduler.enter(delay, priority, action, argument=(), kwargs={})
Delay is a relative time unit from when it enters the queue. Other than the delay parameter, this function behaves identical to enterabs().
scheduler.cancel(event)
Remove the event from the queue. If event is not an event currently in the queue, this method will raise a ValueError.
scheduler.empty()
Return True if the event queue is empty.
scheduler.queue
Read-only attribute returning a list of upcoming events in the order they will be run. Each event is shown as a named tuple with the following fields: time, priority, action, argument, kwargs.
New features:
scheduler.start()
Triggers the EventScheduler to start running, and will start executing actions in its queue depending on delay and priority. A value of 0 is returned on a successful start up and -1 on failure to start.
scheduler.stop()
Will prevent the event scheduler from taking any more actions. The event scheduler will execute the remaining actions (if any). A value of 0 is returned on a successful stop and -1 on failure to stop.
scheduler.run(blocking=True)
This method is now private and should not be called.
Example
Please refer to this code repository for the example. We're going to be creating a bank account and managing transactions with an event scheduler.
In this scenario it's important to have an accurate balance. The "actions" we'll focus on are deposit and withdraw.
Contact
Please email phluentmed@gmail.com or open an issue if you need any help using the code, have any questions, or even have some feature suggestions. If you're experiencing issues, please send the corresponding stack trace or screenshot to help us diagnose the issue.
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:
Release files for event-scheduler 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| event-scheduler-0.0.5.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| event_scheduler-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / event-scheduler-0.0.5.tar.gz
| Download URL | event-scheduler-0.0.5.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9d967c04454cadb04f9586b4b07050c112294105c1ed932bb1f919cbe94cd34
|
|
BLAKE2b-256 checksum How to use checksums |
fdbc1a3a699a4019c3b6f9aa82b74307a3cb3804743c9a7be250d6f18d9d8dd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.0
|
Release files / event_scheduler-0.0.5-py3-none-any.whl
| Download URL | event_scheduler-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3de975e815a103d2502ed081bf716642f407c19c25417d28760a3b25cec13db6
|
|
BLAKE2b-256 checksum How to use checksums |
70fbe91d54ab74cd7f41234a3d733e53b41d31f8914581f09c8835a721e18118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.0
|