Skip to main content

A simple, lightweight event pipeline in Python.

Project description


A simple, lightweight event pipeline in Python.


pip install ap-topical


import logging, asyncio
import ap.topical
logger = logging.getLogger(__name__)

async def start_handler(payload):
    """Do stuff here"""

    await ap.topical.publish('end', payload)

async def start_auditor(payload):'auditing start event')

async def end_handler(payload):
    """Do stuff here"""

async main():
    await ap.topical.publish('start', {})

if __name__ == '__main__':


Events are strings (or other hashable objects) that are published via ap.topical.publish(). These are used as both a topic and a specific event.

Subscribing Callbacks to Events

You can subscribe a callback to a given event using ap.topical.subscribe as in the following example:

async def my_event_handler(payload):

ap.topical.subscribe('my-event', my_event_handler)

Additionally, you can use the handy @ap.topical.event() decorator to do this for you automatically:

async def my_event_handler(payload):

Publishing Events

Events can be published by providing an event and a payload to pass between event handlers.

await ap.topical.publish('my-event', {})

Multiple Handlers

A given event can have any number of handlers (limited by available compute resources). These will all trigger asynchronously.

async def start_handler(payload):

async def start_auditor(payload):

await ap.topical.publish('start', {})

This allows you to create robust graphs of event handlers.

Future Plans

  • add unsubscribe functionality
  • add wildcard event support
  • add default event payload support
  • add payload validation via msgspec

Project details

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ap_topical-0.3.1-py3-none-any.whl (2.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