Thanks for all the suggestions, I am unable to try them out as I'm at work but think I know where to go tonight.
I found reference to: sys.setcheckinterval(interval) Which can change the number of python 'instructions' between thread swaps (default value is 100). However I don't think that this will help as the thread is locked up in C/C++ code. I also found this document which looks more promising: http://teckla.idyll.org/~t/transfer/public/day3.pdf It explains how the thread model/GIL prevents wrapper code running on multiple core, but does suggest this handy hint -- Basically, just wrap I/O blocking code or CPU-intensive code in the following macros: Py_BEGIN_ALLOW_THREADS ...Do some time-consuming operation... Py_END_ALLOW_THREADS > > 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 > > --- On Wed, 3/18/09, [email protected] <[email protected]> wrote: > >> From: [email protected] <[email protected]> >> Subject: [clug-talk] Moving CPU Intensive Thread to lower Priority? >> To: [email protected] >> Cc: [email protected] >> Date: Wednesday, March 18, 2009, 10:25 AM >> 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. >> >> >> _______________________________________________ >> 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 >> > > > > > _______________________________________________ > 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 > _______________________________________________ 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

