Example #1
0
File: pages.py Project: Lax/Sloth
def getmatch(key):
    d = []
    for ks, item in tree.query(app.tree, key):
        d.append((','.join(ks), item))

    d.sort(key=lambda x: x[0])
    return d
Example #2
0
File: core.py Project: Lax/Sloth
def update(d):
    lived = [key for key in waiters.live_signals if tree.keyin(key, d)]
    #print 'live', waiters.live_signals, lived
    for key in lived:
        fd = {}
        for ks, x in tree.query(d, key):
            fd[','.join(ks)] = x
        #print 'fire', key, fd
        waiters.send(key, fd)

    # update
    #print 'update:', d
    tree.merge(_tree, d)

    # need dump tree?
    global _last_update, _last_dump
    now = time.time()
    if _last_dump is None or now - _last_dump > dump_interval:
        tick_later()
    _last_update = time.time()