Skip to main content

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

This repository is licensed under the MIT license See LICENSE for details

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

airignis-0.0.3.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airignis-0.0.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file airignis-0.0.3.tar.gz.

File metadata

  • Download URL: airignis-0.0.3.tar.gz
  • Upload date:
  • Size: 17.1 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

Hashes for airignis-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a383bb200ba45ab37294be78033c8d7a6a3b64331bc6818a600daa524e900860
MD5 72a718eed2c18c0c643e1e2b893bc3a9
BLAKE2b-256 2674270fc2f467ae0d3f06c714f74f412b53ecd7df9f48abdeefdf702550fc99

See more details on using hashes here.

File details

Details for the file airignis-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: airignis-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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

Hashes for airignis-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8e7a6357a489fe5475a93f9322eb40243a6b62cf70b23c0ec5e7ea9f3630e16b
MD5 917f31d25b872bb16685e53e71f3c122
BLAKE2b-256 bc0198296bf2c02da1577b7786fd9a606ef3975c7d8c3df550bd15dd56d13216

See more details on using hashes here.

Supported by

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