Skip to main content

The Blinker Herald includes helpers to easily emit signals using Blinker. Decorate a function or method with @blinker_herald.emit() and pre and post signals will automatically be emitted to connected handlers.

Project description

Blinker Herald

https://img.shields.io/pypi/v/blinker_herald.svg https://img.shields.io/travis/rochacbruno/blinker_herald.svg Documentation Status docs/The_Herald.jpg

The Blinker Herald includes helpers to easily emit signals using the excelent blinker library.

Decorate a function or method with @blinker_herald.emit() and pre and post signals will be automatically emitted to all connected handlers.

Features

  • All the features provided by blinker

    • An easy decorator @emit() to magically emit signals when your functions are called and before it returns a result.

  • Customizable for your needs

Let’s say you have a class that does something:

from blinker_herald import emit

class SomeClass(object):
    @emit()
    def do_something(self, arg1):
        # here is were magically the 'pre' signal will be sent
        return 'something done'
        # here is were magically the 'post' signal will be sent

using @emit decorator makes blinker_herald to emit a signal for that method and now you can connect handlers to capture that signals

You can capture pre signal to manipulate the object:

SomeClass.do_something.pre.connect
def handle_pre(sender, signal_emitter, **kwargs):
    signal_emitter.foo = 'bar'
    signal_emitter.do_another_thing()

And you can also capture the post signal to log the results:

SomeClass.do_something.post.connect
def handle_post(sender, signal_emitter, result, **kwargs):
    logger.info("The method {0} returned {1}".format(sender, result))

Credits

This software was first created by SatelliteQE team to provide signals to Robottelo and Nailgun

History

0.1.0 (2016-05-28)

  • First release on PyPI.

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

blinker_herald-0.1.0.tar.gz (134.3 kB view details)

Uploaded Source

Built Distribution

blinker_herald-0.1.0-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file blinker_herald-0.1.0.tar.gz.

File metadata

File hashes

Hashes for blinker_herald-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4247bd92904bfb10251dcc360a2bbb34477f4e92748588d74880483c231e2967
MD5 96453d514c80e5418a7cae6ea73f90c4
BLAKE2b-256 3c2e540a1669ebf5eaf3e781073dfc1ed86a8dafed6628aeb325f3b93f55896e

See more details on using hashes here.

File details

Details for the file blinker_herald-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for blinker_herald-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3aae5c921ce67ef403ca4b57500b5e2070b56e80e2b1aef153970d7ed18493f2
MD5 29d85d2abb1d5e022c1ec4d9e688baa0
BLAKE2b-256 3941a2d0883331a05eac2843f980465e0a49ea99057b0e1b107c15fa09269dba

See more details on using hashes here.

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