[wxPython-users] Can you limit CPU resources for the running app ?
Anders J. Munch
ajm at flonidan.dk
Thu Jan 17 02:47:04 PST 2008
Robin Dunn wrote:
> I know that there is a win32 API for limiting a process to just one CPU,
> so I expect that there are APIs for setting priority (like unix's nice()
> function) but I don't know details. Searching MSDN will probably turn
> up something, and then you can probably use ctypes to call it.
import ctypes
w32 = ctypes.windll.kernel32
NORMAL_PRIORITY_CLASS = 0x00000020
IDLE_PRIORITY_CLASS = 0x00000040
HIGH_PRIORITY_CLASS = 0x00000080
REALTIME_PRIORITY_CLASS = 0x00000100
def ChangesProcessPriorityClass(new_class):
proc_pseudohandle = w32.GetCurrentProcess()
retv = w32.SetPriorityClass(proc_pseudohandle, new_class)
if retv == 0:
werrno = w32.GetLastError()
raise EnvironmentError('SetPriorityClass -> %d' % (werrno,))
- Anders
More information about the wxpython-users
mailing list