Threading & garbage collection
Gordon McMillan
gmcm at hypernet.com
Wed Jan 12 09:11:02 EST 2000
Matt Gushee wrote:
> I'm trying to write a subclass of threading.Thread where each
> thread:
>
> 1) is invoked by a GUI event handler
> 2) collects some data (to be exact, it downloads a web page
> and extracts some information from it), and finally
> 3) invokes a GUI method to display the data
It would probably be wise (and with some GUIs, absolutely
vital) to make sure that all the GUI calls are made on the GUI
thread. In other words, the worker thread should probably post
the data to the GUI thread somehow. Queue.py is a likely
candidate for passing the data. Depending on the GUI, you
may be able to notify the GUI thread when the data is
available, or the GUI thread may have to periodically check for
it.
> ...Do the standard
> rules about circular references apply to threads? I.e., should I
> add something like:
>
> self.win = None
>
> to the above?
Sure thing.
- Gordon (who lives 2.5 hrs downeast from you)
More information about the Python-list
mailing list