Nicing a thread

jesper jesper.webmail at gmail.com
Tue Apr 14 05:06:58 EDT 2009


Hi,

I would like to spawn a thread (on Unix) with a lower priority (higher
niceness) than the main thread (which should stay at nice 0). What I
have done is something like:

import threading, os
class MyThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        os.nice(19)
        a_useful_method()

It seems to work but I am a bit sure whether I missed anything (I am
not that familiar with threading). What do you experts say?

Best regards,
Jesper



More information about the Python-list mailing list