How to use the blinker.ANY 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 CenterForOpenScience / osf.io / api_tests / utils.py View on Github external
def disconnected_from_listeners(signal):
    """Temporarily disconnect all listeners for a Blinker signal."""
    listeners = list(signal.receivers_for(ANY))
    for listener in listeners:
        signal.disconnect(listener)
    yield
    for listener in listeners:
        signal.connect(listener)
github hebenon / oversight / tests / test_pushover_notifier.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in trigger_event.receivers_for(ANY):
        trigger_event.disconnect(receiver)
github hebenon / oversight / tests / test_monitor.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in image_analysis.receivers_for(ANY):
        image_analysis.disconnect(receiver)

    for receiver in trigger_event.receivers_for(ANY):
        trigger_event.disconnect(receiver)
github jek / blinker / tests / test_signals.py View on Github external
sentinel = []
    def meta_received(sender, **kw):
        sentinel.append(dict(kw, sender=sender))

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

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

    assert sentinel == [dict(sender=sig,
                             receiver_arg=receiver,
                             sender_arg=blinker.ANY,
                             weak_arg=True)]

    blinker.receiver_connected._clear_state()
github biosustain / potion / tests / backends / peewee / test_peewee_signals.py View on Github external
    def assertSignals(self, expected_events, sender=ANY):
        events = []

        def receiver_(signal, sender, **kwargs):
            events.append((signal, sender, kwargs))

        receivers = {
            signal: partial(receiver_, signal) for signal in [
            signals.before_create,
            signals.after_create,
            signals.before_update,
            signals.after_update,
            signals.before_delete,
            signals.after_delete,
            signals.before_add_to_relation,
            signals.after_add_to_relation,
            signals.before_remove_from_relation,
github hebenon / oversight / tests / test_image_buffer.py View on Github external
def teardown():
    # Disconnect any triggers
    for receiver in image.receivers_for(ANY):
        image.disconnect(receiver)

    for receiver in image_buffer.receivers_for(ANY):
        image_buffer.disconnect(receiver)
github moinwiki / moin / src / moin / utils / notifications.py View on Github external
@item_modified.connect_via(ANY)
def send_notifications(app, fqname, **kwargs):
    """ Send mail notifications to subscribers on item change

    :param app: local proxy app
    :param fqname: fqname of the changed item
    :param kwargs: key/value pairs that contain extra information about the item
                   required in order to create a notification
    """
    action = kwargs.get('action')
    revs = get_item_last_revisions(app, fqname) if action not in [
        DESTROY_REV, DESTROY_ALL, ] else []
    notification = Notification(app, fqname, revs, **kwargs)
    try:
        content_diff = notification.get_content_diff()
    except Exception:
        # current user has likely corrupted an item or fixed a corrupted item
github biosustain / potion / examples / permissions_example.py View on Github external
@signals.before_create.connect_via(ANY)
def before_create_article_comment(sender, item):
    if issubclass(sender, (ArticleResource, CommentResource)):
        item.author_id = current_user.id
github jmcarp / nplusone / nplusone / core / signals.py View on Github external
def get_worker(*args, **kwargs):
    return blinker.ANY
github moinwiki / moin / MoinMoin / util / notifications.py View on Github external
@item_modified.connect_via(ANY)
def send_notifications(app, fqname, **kwargs):
    """ Send mail notifications to subscribers on item change

    :param app: local proxy app
    :param fqname: fqname of the changed item
    :param kwargs: key/value pairs that contain extra information about the item
                   required in order to create a notification
    """
    action = kwargs.get('action')
    revs = get_item_last_revisions(app, fqname) if action not in [
        DESTROY_REV, DESTROY_ALL, ] else []
    notification = Notification(app, fqname, revs, **kwargs)
    try:
        content_diff = notification.get_content_diff()
    except Exception:
        # current user has likely corrupted an item or fixed a corrupted item