Skip to main content

Non-stop running event scheduler

Project description

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.

EventScheduler GitHub

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

event-scheduler-0.0.5.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

event_scheduler-0.0.5-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file event-scheduler-0.0.5.tar.gz.

File metadata

  • Download URL: event-scheduler-0.0.5.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for event-scheduler-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a9d967c04454cadb04f9586b4b07050c112294105c1ed932bb1f919cbe94cd34
MD5 457932cf7fde40238b587865a8107e93
BLAKE2b-256 fdbc1a3a699a4019c3b6f9aa82b74307a3cb3804743c9a7be250d6f18d9d8dd9

See more details on using hashes here.

File details

Details for the file event_scheduler-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: event_scheduler-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for event_scheduler-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3de975e815a103d2502ed081bf716642f407c19c25417d28760a3b25cec13db6
MD5 f4ed72ef8f9268e35b26358e797ff375
BLAKE2b-256 70fbe91d54ab74cd7f41234a3d733e53b41d31f8914581f09c8835a721e18118

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page