Commit 253debb9 authored by Anael Beutot's avatar Anael Beutot Committed by Antoine Millet
Browse files

Added background introspection feature + decorator

parent f24067f7
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -181,19 +181,21 @@ def tag_inspector(mod, parent=None):
            # if string, it means it is constant, then ttl = -1
            ttl = -1
            refresh = None
            background = False
        elif inspect.isfunction(m):
            # if function take function ttl argument or set -1 by default
            ttl = getattr(m, 'ttl', -1)
            refresh = getattr(m, 'refresh', None)
            background = getattr(m, 'background', False)
        else:
            # whatever it is we don't care...
            continue

        logger.debug('Introspected %s with ttl %s, refresh %s for object %s',
                     n, ttl, refresh, parent)
        logger.debug('Introspected %s with ttl %s, refresh %s, background %s for object %s',
                     n, ttl, refresh, background, parent)

        # finally add the tag
        tags.append(Tag(n, m, ttl, refresh, parent))
        tags.append(Tag(n, m, ttl, refresh, parent, background))

    return tags

@@ -213,6 +215,11 @@ def refresh(value):
    return decorator


def background(func):
    func.background = True
    return func


def get_tags(tags_dict, tags=None):
    """Helper to get tags.