![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Setting a Script's CPU Priority
I have two scripts running on my server,
- the server-side script which handles all incoming traffic - a server manager which automatically makes backups, configures my IP, reboots the server, etc... The server-side script has been reconfigured through CherryPy to only take up 3-4 CPU cycles. Python by default will take up all the remaining CPU cycles. This raises a problem. My server manager takes up %96 of my CPU, doing nothing but waiting for a checkpoint while my server-side script slowly fulfills the main purpose of the computer. How would I flip these CPU priorities around, making CherryPy by default take up the remaining cycles (instead of 3-4), and Python only take up 3-4? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
If you're using Linux, or something similar, would using the renice and nice commands help?
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Nope, windows XP. Because I needed something that could be conveniently accessed from the shared folders, and used os calls I already knew.
|
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
There is (unsurprisingly) an os.nice method to set the priority level, but i'm not sure if this only available on posix systems. Do you have that method available?
|
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
>>> import os
>>> os.nice() Quote:
|
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
FOUND IT!
=D from os import system system( "start /realtime c:/windows/notepad.exe" ) # /low - Priority 4 # /belownormal - Priority 6 # /normal - Priority 8 # /high - Priority 13 # /realtime - Priority 24 So that would open notepad with a priority of 24/31. Yay. |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Don't use /realtime - it can screw things up. It takes a higher priority than critical system tasks - I can't explain why, but that be a Bad Thing. Use /high.
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
What's an example of a critical system task?
|
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Y'know, I don't actually know. I'm really just spouting what I've been told, but I can kinda see why it would be a problem.
|
|
|
|
|
|
#10 |
|
Expert Programmer
|
Well i'm guessing here. Push ctrl+alt+del and clcik the processes tab, then look for SYSTEM processes, I would assume that at least one of those is vital.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|