[clug-talk] Moving CPU Intensive Thread to lower Priority?
Mark Carlson
carlsonmark at gmail.com
Wed Mar 18 09:33:42 PDT 2009
On 3/18/09, Chris Lusena <grey_0x1a at yahoo.com> wrote:
>
> Can you access the main loop of the processing (CPU bound) thread?
> If so you could try using time.sleep() to stop the cpu bound thread for a moment and give others a shot at the interpreter. Also you could (restructuring your project) put the processing in another process via something like os.popen or subprocess (in 2.6/3.0), sockets or pipes for communication, nice the process if necessary. Unix process are cheep, more advice I have read on the subject boils down to multi-process where possible or multi-threading With a quick glance at documentation I could not find a way to set a priority of a thread under python ether.
>
> --
> Chris
Changing a thread priority is one of those things that's not in Python
right now, and will not be for the foreseeable future.
Doing a grep for "pthread_attr_setschedparam" in the Python source
code reveals nothing (on 2.2.2 and 2.4.6, the source tarballs I have
unpacked right now.)
Due to the Global Interpreter Lock, I'm not sure it would even be a
good idea to have prioritized threads, even though you could do it if
you write a few lines of C code.
-Mark C.
More information about the clug-talk
mailing list