-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Background_Mode begin and end constants #1589
base: master
Are you sure you want to change the base?
Conversation
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass shows to further constants which do actually work for example in windows 7. PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 Begin background processing mode. The system lowers the resource scheduling priorities of the process (and its threads) so that it can perform background work without significantly affecting activity in the foreground. This value can be specified only if hProcess is a handle to the current process. The function fails if the process is already in background processing mode. Windows Server 2003 and Windows XP: This value is not supported. PROCESS_MODE_BACKGROUND_END 0x00200000 End background processing mode. The system restores the resource scheduling priorities of the process (and its threads) as they were before the process entered background processing mode. This value can be specified only if hProcess is a handle to the current process. The function fails if the process is not in background processing mode. Windows Server 2003 and Windows XP: This value is not supported.
Looks like you want to merge #1590 into this one. Also, those 2 constants are not available on Windows XP and 2003, so what I would suggest is this: //psutil/ _psutil_windows.c
+ PyModule_AddIntConstant(
+ module, "PROCESS_MODE_BACKGROUND_BEGIN", 0x00100000);
+ PyModule_AddIntConstant(
+ module, "PROCESS_MODE_BACKGROUND_END", 0x00200000); # psutil/_pswindows.py
if enum is not None:
class Priority(enum.IntEnum):
ABOVE_NORMAL_PRIORITY_CLASS = ABOVE_NORMAL_PRIORITY_CLASS
BELOW_NORMAL_PRIORITY_CLASS = BELOW_NORMAL_PRIORITY_CLASS
HIGH_PRIORITY_CLASS = HIGH_PRIORITY_CLASS
IDLE_PRIORITY_CLASS = IDLE_PRIORITY_CLASS
NORMAL_PRIORITY_CLASS = NORMAL_PRIORITY_CLASS
REALTIME_PRIORITY_CLASS = REALTIME_PRIORITY_CLASS
+ if get_winver() > WIN_SERVER_2003:
+ Priority.PROCESS_MODE_BACKGROUND_BEGIN = \
+ cext.PROCESS_MODE_BACKGROUND_BEGIN
+ Priority.PROCESS_MODE_BACKGROUND_END = \
+ cext.PROCESS_MODE_BACKGROUND_END
globals().update(Priority.__members__)
+ if get_winver() > WIN_SERVER_2003:
+ __extra_all__.append('PROCESS_MODE_BACKGROUND_BEGIN')
+ __extra_all__.append('PROCESS_MODE_BACKGROUND_END') # psutil/__init__.py
elif WINDOWS:
from . import _pswindows as _psplatform
from ._psutil_windows import ABOVE_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import BELOW_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import HIGH_PRIORITY_CLASS # NOQA
from ._psutil_windows import IDLE_PRIORITY_CLASS # NOQA
from ._psutil_windows import NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import REALTIME_PRIORITY_CLASS # NOQA
from ._pswindows import CONN_DELETE_TCB # NOQA
from ._pswindows import IOPRIO_VERYLOW # NOQA
from ._pswindows import IOPRIO_LOW # NOQA
from ._pswindows import IOPRIO_NORMAL # NOQA
from ._pswindows import IOPRIO_HIGH # NOQA
+ if 'PROCESS_MODE_BACKGROUND_BEGIN' in _psplatform.__extra_all__:
+ from ._psutil_windows import PROCESS_MODE_BACKGROUND_BEGIN # NOQA
+ from ._psutil_windows import PROCESS_MODE_BACKGROUND_END # NOQA |
Also, please rebase this branch as I added a fix for the test failure shown by appveyor. |
Hi, Kind regards |
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass shows to further constants which do actually work for example in windows 7.
PROCESS_MODE_BACKGROUND_BEGIN
0x00100000
Begin background processing mode. The system lowers the resource scheduling priorities of the process (and its threads) so that it can perform background work without significantly affecting activity in the foreground.
This value can be specified only if hProcess is a handle to the current process. The function fails if the process is already in background processing mode.
Windows Server 2003 and Windows XP: This value is not supported.
PROCESS_MODE_BACKGROUND_END
0x00200000
End background processing mode. The system restores the resource scheduling priorities of the process (and its threads) as they were before the process entered background processing mode.
This value can be specified only if hProcess is a handle to the current process. The function fails if the process is not in background processing mode.
Windows Server 2003 and Windows XP: This value is not supported.