Skip to main content

General Events Manager

Project description

Gev (General Events Manager)

$ pip install gev

Usage

from gev import Event, EventManager

manager = EventManager()

def handler_1(e):
    print("handler_1 called with", e)

def handler_2(e):
    print("handler_2 called with", e)

# Register event handlers
manager.on('sys_1::event_a').do(handler_1)
manager.on('sys_1::event_b').do(handler_2)

manager.take(Event(
    source='sys_1',
    type='event_a',
    payload={'a': 1}
))  # handler_1 will be called

manager.take(Event(
    source='sys_1',
    type='event_b',
    payload={'b': 1}
))  # handler_1 will be called

If you don't want to initialize an EventManager instance, you can use the global default_manager and its on and take methods exposed at module level.

from gev import on, take, Event

def handler_1(e):
    print("handler_1 called with", e)

on('sys_1::event_a').do(handler_1)

take(Event(
    source='sys_1',
    type='event_a',
    payload={'a': 1}
))  # handler_1 will be called

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

gev-0.1.2.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

gev-0.1.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

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