How to use the blinker.base function in blinker

To help you get started, we’ve selected a few blinker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heston / firebase-live-data / tests / test_live.py View on Github external
def test_signal(self, livedata):
        signal = livedata.signal('/foo/bar')
        assert isinstance(signal, blinker.base.Signal)
github jek / blinker / tests / test_signals.py View on Github external
def test_meta_connect_failure():
    def meta_received(sender, **kw):
        raise TypeError('boom')

    assert not blinker.receiver_connected.receivers
    blinker.receiver_connected.connect(meta_received)

    def receiver(sender, **kw):
        pass
    sig = blinker.Signal()

    assert_raises(TypeError, sig.connect, receiver)
    assert not sig.receivers
    assert not sig._by_receiver
    assert sig._by_sender == {blinker.base.ANY_ID: set()}

    blinker.receiver_connected._clear_state()
github eleme / meepo / meepo / signals.py View on Github external
def _monkey_patch_hashable_func():
    def hashable_identity(obj):
        if hasattr(obj, '__func__'):
            return (id(obj.__func__), id(obj.__self__))
        elif hasattr(obj, 'im_func'):
            return (id(obj.im_func), id(obj.im_self))
        elif isinstance(obj, (str, bytes)):
            return obj
        # hack for session hash info
        elif hasattr(obj, "info") and obj.info:
            return hash(str(sorted(obj.info.items())))
        else:
            return id(obj)

    import blinker.base
    blinker.base.hashable_identity = hashable_identity
_monkey_patch_hashable_func()