示例#1
0
def rush(enable=True, realtime=False):
    """Raise the priority of the current thread/process

    Set with rush(True) or rush(False)

    Beware and don't take priority until after debugging your code
    and ensuring you have a way out (e.g. an escape sequence of
    keys within the display loop). Otherwise you could end up locked
    out and having to reboot!
    """
    if importWindllFailed:
        return False

    pr_rights = PROCESS_QUERY_INFORMATION | PROCESS_SET_INFORMATION
    pr = windll.OpenProcess(pr_rights, FALSE, os.getpid())
    thr = windll.GetCurrentThread()

    if enable is True:
        if realtime is False:
            windll.SetPriorityClass(pr, HIGH_PRIORITY_CLASS)
            windll.SetThreadPriority(thr, THREAD_PRIORITY_HIGHEST)
        else:
            windll.SetPriorityClass(pr, REALTIME_PRIORITY_CLASS)
            windll.SetThreadPriority(thr, THREAD_PRIORITY_TIME_CRITICAL)

    else:
        windll.SetPriorityClass(pr, NORMAL_PRIORITY_CLASS)
        windll.SetThreadPriority(thr, THREAD_PRIORITY_NORMAL)
    return True
示例#2
0
def rush(value=True):    
    """Raise the priority of the current thread/process 
    Win32 and OS X only so far - on linux use os.nice(niceIncrement)
    
    Set with rush(True) or rush(False)
    
    Beware and don't take priority until after debugging your code
    and ensuring you have a way out (e.g. an escape sequence of
    keys within the display loop). Otherwise you could end up locked
    out and having to reboot!
    """
    if importWindllFailed:
        return False
    
    thr=windll.GetCurrentThread()
    pr =windll.GetCurrentProcess()
    if value:
            windll.SetPriorityClass(pr, REALTIME_PRIORITY_CLASS)
            windll.SetThreadPriority(thr, THREAD_PRIORITY_TIME_CRITICAL)
    else:
            windll.SetPriorityClass(pr, NORMAL_PRIORITY_CLASS)
            windll.SetThreadPriority(thr, THREAD_PRIORITY_NORMAL)
    return True