[Tutor] Reading in file and processing it in a thread

vicki at thepenguin.org vicki at thepenguin.org
Sat Jul 24 19:08:30 CEST 2004

> Using the same variable in multiple threads (in this case, 'self' if
> nothing else) is very likely to cause problems.  In particular, access
> to any wx.Python GUI elements across threads is *not* safe.   Make
> your threaded function entirely independent of the rest of your code
> (and make it a function rather than a method, unless it's a method of
> a new object), and then use documented-threadsafe methods to get
> information back from it.  (IIRC, wx.PostEvent() will deliver
> an event to the main GUI thread in a safe manner; just define a custom
> event for the main thread to listen for, and have your threaded
> function post that event with the necessary information attached.)

Thanks. I need to digest all that you wrote here. I am totally new to
threaded programmming, and there seems to be a shortage of published books
on the subject. I'm sure I'll have more questions as I go along.

> By the way, is there any reason that you're using the thread module
> instead of the threading module?  The latter is a higher-level, more
> user-friendly interface built on top of thread, and is usually the
> recommended module for use.

Only lack of knowledge. I found the thread module first.

Thanks again,

More information about the Tutor mailing list