Skip to main content

An event driven middleware library for Python

Project description

.. image:: :target: :alt: build status

.. image:: :target: :alt: coverage status


pyeventsystem is an event-driven middleware library for Python. In addition to providing a mechanism for subscribing and listening to events, it also provides a mechanism for intercepting functions, thus making it suitable for writing middleware. By intercepting functions, middleware can be injected before, after or even replacing the original function. It also provides capabilities for grouping related event handlers into middleware classes, making it easier to manage installable middleware.

Simple Example

.. code-block:: python

from pyeventsystem.middleware import SimpleMiddlewareManager
from pyeventsystem.middleware import dispatch
from pyeventsystem.middleware import observe

class MyMiddleWare(object):

    def __init__(self, event_dispatcher): = event_dispatcher

    @dispatch("", priority=2500)
    def perform_villainy(self, name):
        return "Drop ACME Anvil on " + name

    @observe("", priority=2400)
    def pre_log_villainy(self, event_args, name):
        print("Prepping for villainy: " + name)

    @observe("*", priority=2600)
    def post_log_villainy(self, event_args, name):
        print("Result of villainy: {0}".format(event_args['result']))

manager = SimpleMiddlewareManager()
myobj = MyMiddleWare(

In this example, we have intercepted the perform_villainy function, and observed the function both before and after execution.

The output is:

.. code-block:: console

Prepping for villainy: RoadRunner
Result of villainy: Drop ACME Anvil on RoadRunner

Download files

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

Source Distribution

pyeventsystem-0.1.0.tar.gz (13.5 kB view hashes)

Uploaded source

Built Distribution

pyeventsystem-0.1.0-py2.py3-none-any.whl (15.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page