Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Threading is actually fair

2 views
Skip to first unread message

Matt Kimball

unread,
May 21, 2002, 11:06:31 AM5/21/02
to
Okay, Tim was right, of course. Python's global interpreter lock wasn't the
cause of any of my complaints about threading unfairness.

For those interested, part of the problem was that my background computation
thread was flooding my GUI with "update" events, telling my main GUI thread that
it had new data and wanted to repaint its views of said data. I throttled that
back so that it doesn't send an update more frequently than every 100 ms and it
helped a bit.

The second half of the solution was actually to set the thread priority of my
background computation to something lower than the GUI thread. This made the
GUI responsiveness much, much better. Using win32all, in my background
computation thread, I do this before any of the real work:

win32process.SetThreadPriority(win32api.GetCurrentThread(),
win32process.THREAD_PRIORITY_BELOW_NORMAL)

And from there on out, things run very smoothly.

--
Matt Kimball
ma...@kimball.net

Aahz

unread,
May 21, 2002, 2:57:20 PM5/21/02
to
In article <mailman.102199372...@python.org>,

Matt Kimball <ma...@kimball.net> wrote:
>
>For those interested, part of the problem was that my background
>computation thread was flooding my GUI with "update" events, telling my
>main GUI thread that it had new data and wanted to repaint its views
>of said data. I throttled that back so that it doesn't send an update
>more frequently than every 100 ms and it helped a bit.

For a better way, see the thread tutorial on mt web site.
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/

"In the end, outside of spy agencies, people are far too trusting and
willing to help." --Ira Winkler

0 new messages