示例#1
0
 def _register(watch_states, notifier, cb):
     registered = []
     try:
         for s in watch_states:
             if not notifier.is_registered(s, cb):
                 notifier.register(s, cb)
                 registered.append((s, cb))
     except ValueError:
         with excutils.save_and_reraise_exception():
             for (s, cb) in registered:
                 notifier.deregister(s, cb)
示例#2
0
def _bulk_register(watch_states, notifier, cb, details_filter=None):
    """Bulk registers a callback associated with many states."""
    registered = []
    try:
        for state in watch_states:
            if not notifier.is_registered(state, cb,
                                          details_filter=details_filter):
                notifier.register(state, cb,
                                  details_filter=details_filter)
                registered.append((state, cb))
    except ValueError:
        with excutils.save_and_reraise_exception():
            _bulk_deregister(notifier, registered,
                             details_filter=details_filter)
    else:
        return registered
示例#3
0
def _bulk_register(watch_states, notifier, cb, details_filter=None):
    """Bulk registers a callback associated with many states."""
    registered = []
    try:
        for state in watch_states:
            if not notifier.is_registered(state, cb,
                                          details_filter=details_filter):
                notifier.register(state, cb,
                                  details_filter=details_filter)
                registered.append((state, cb))
    except ValueError:
        with excutils.save_and_reraise_exception():
            _bulk_deregister(notifier, registered,
                             details_filter=details_filter)
    else:
        return registered