Looking for a C# familiar package to handle events or looking for a very practical and intuitive way to schedule periodically launching auto event? Then this package is for you.
Project description
Airignis
This package aims to provide a C# familiar way of handling events in addition to the possibility to schedule the execution of periodic events on different time bases (year, month, weak, day, hour, minute, second) called auto events. When using this package, please keep in mind that the timing precision of the auto event executions mainly depends on the real-time ability of your operating system. Therefore, it is not intended for applications requiring a high level of timing precision.
Installation
$ pip install airignis
How to use this package?
Create an Event and add subscriber's callbacks
from airignis import Event
def foo(data):
print(f"doing something with the data: {data}")
# creating an Event object
my_event = Event()
# adding the foo() function as subscriber callback
my_event += foo
After importing the Event class an object can be created. Following, one or multiple callback functions can be added with the += operator.
Invoke the Event and pass arguments to the callback
my_event.invoke(data)
The type and number of arguments of the subscriber callbacks must match with the data template accepted by the Event.
Remove a subscriber's callback
# removing the foo() function from the list of subscriber callbacks
my_event -= foo
Schedule an AutoEvent and set the function to be executed at each due time
This example shows a minimalistic usage of the AutoEvent class. Please refer to the package documentation for a detailed showcase of the functionalities.
from airignis import AutoEvent, duetime
from datetime import datetime, timedelta
def say_hello(name: str):
print(f"Hello {name}")
rate = 2
rate_unit = 'second'
exec_time = 20
# Specify the target due time
test_due_time = duetime(rate=rate, rate_unit=rate_unit)
# Defining the stop date time of the auto event. Should stop after 20 seconds
stop_datetime = datetime.now(test_due_time.timezone) + timedelta(seconds=exec_time)
auto_event = AutoEvent(say_hello, test_due_time, stop_datetime, 'world')
# starting the auto event handler
auto_event.start()
# Interrupting the auto event handler
auto_event.stop()
License
© 2022 Subvael
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file airignis-0.0.4.tar.gz.
File metadata
- Download URL: airignis-0.0.4.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87dd61449b7cee8b792ea572ce8b91b95db5008310f9471e8dc9d8231906615e
|
|
| MD5 |
b06ccc4fb2c4ec4e9017833195dbbf91
|
|
| BLAKE2b-256 |
5a90c68abca967d5dd330e9f656bf60797853a804fdd5fb9e09408787f9f2652
|
File details
Details for the file airignis-0.0.4-py3-none-any.whl.
File metadata
- Download URL: airignis-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c27fc92811c3b57e803f3a6fb8d32c18d9cc207a47c2af090ebf01f5e342ea3
|
|
| MD5 |
156aacb12f288c4f2245e499e3371a6a
|
|
| BLAKE2b-256 |
dfce4064180fdd472a67571c98d7d3ee3bf8b5aec5da24ec099096c7afd9bd1c
|