On 3/18/09, [email protected] <[email protected]> wrote:
> Hi all,
>  I have a question this week about thread priority, the little python
>  application I am writing is CPU bound (on my crappy old machine).
>
>  I have split the application into threads (using threading) which appears
>  to work OK, but the application is still responding at the speed of the
>  slowest thread.
>
>  The app is a video processing/display, I have:
>  --
>  Main Thread: pyGTK display/buttons.
>  Capture Thread: grab from V4L2 and render onto display.
>  Process Thread: grab image from Capture thread and process, processing is
>  done using a wrapper to C library.
>  --
>
>  The video display framerate drops to that of the processing thread and the
>  CPU is pegged at 100%. If I disable the processing thread then the video
>  is smooth, with the correct framerate and CPU is mostly idle.
>
>  If I put a large sleep (5s for example) in the processing thread I get
>  slow video (whilst processing) and then smooth video (whilst sleeping), so
>  I believe that I have done the threading correctly.
>
>  So my questions are:
>  Is there a way to lower the priority of the 'Process Thread' so that it
>  does not run as intensively?
>  Or, is there a way to increase the rate at which the 'Process Thread' is
>  swapped out and thus allowing the other (less intensive) threads to get
>  CPU time?
>
>  Cheers,
>  Simon.

If possible, I would suggest trying to use the Popen2 module.  This
way, you should be able to re-nice it (os.nice) after the fork.  This
may be easy or painful depending on how much the thread needs to talk
to it's parent.

-Mark C.

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

Reply via email to