示例#1
0
def __manager():
    temp = 0
    framedelay = 1.0 / config['max-frame-rate']
    mindelay = config['delay-between-frames']
    global averageFramesPerSecond
    averageFramesPerSecond = 0
    #Basically loops for the lief of the app
    while run:
        #Get the time at the start of the loop
        temp = time.time()
        with _event_list_lock:
            for i in _events:
                workers.do(i.check)

            #Don't spew another round of events until the last one finishes so we don't fill up the queue
            e = threading.Event()

            def f():
                e.set()

            workers.do(f)
            #On the of chance something odd happens, let's not wait forever.
            e.wait(15)

        #Limit the polling cycles per second to avoid CPU hogging
        #Subtract the time the loop took from the delay
        #Allow config to impose a minimum delay
        time.sleep(max(framedelay - (time.time() - temp), mindelay))
        #smoothing filter
        averageFramesPerSecond = (averageFramesPerSecond * 0.98) + (
            (1 / (time.time() - temp)) * 0.02)
示例#2
0
def __manager():
    temp = 0;
    framedelay = 1.0/config['max-frame-rate']
    mindelay = config['delay-between-frames']
    global averageFramesPerSecond
    averageFramesPerSecond = 0
    #Basically loops for the lief of the app
    while run:
        #Get the time at the start of the loop
        temp = time.time()
        with _event_list_lock:
            for i in _events:
                workers.do(i.check)
                
            #Don't spew another round of events until the last one finishes so we don't fill up the queue
            e = threading.Event()
            def f():
                e.set()
            workers.do(f)
            #On the of chance something odd happens, let's not wait forever.
            e.wait(15)
            
        #Limit the polling cycles per second to avoid CPU hogging
        #Subtract the time the loop took from the delay
        #Allow config to impose a minimum delay
        time.sleep(max(framedelay-(time.time()-temp),mindelay))
        #smoothing filter
        averageFramesPerSecond = (averageFramesPerSecond *0.98) +   ((1/(time.time()-temp)) *0.02)
def __manager():
    while run:
        __event_list_lock.acquire()
        try:
            for i in __events:
                workers.do(i.check)
        except:
            print("e")
        finally:
            __event_list_lock.release()
            time.sleep(0.025)
def messagelistener(topic,message):
    global log
    global approxtotallogentries
    if topic not in log:
        log[topic] = []
    
    log[topic].append((time.time(),message))
    #This is not threadsafe. Hence the approx.
    approxtotallogentries +=1
    if approxtotallogentries > config['log-dump-size']:
        print('dumped')
        workers.do(dumpLogFile)
示例#5
0
 def do(f):
     workers.do(f)
示例#6
0
 def do(f):
     workers.do(f)