Skip to content

phlax/aio.signals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aio.signals

Pubsub system for the aio asyncio framework

Build status

https://travis-ci.org/phlax/aio.signals.svg?branch=master

Installation

Requires python >= 3.4

Install with:

pip install aio.signals

Quickstart

The listen function is called synchronously, but the callback listener will be called as a coroutine if it isnt one

The callback listener receives a signal object that has the name of the signal and the object that the signal was emitted with

The emit function is a coroutine

Add the following code to a file my_signals.py

import asyncio
from aio.signals import Signals

def listener(signal):
    yield from asyncio.sleep(1)
    print(signal.data)

signals = Signals()
signals.listen("my-signal", listener)

loop = asyncio.get_event_loop()
loop.run_until_complete(
    signals.emit("my-signal", 'BOOM!'))

Run with

python my_signals.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages