thread vs GC

"Martin v. Löwis" martin at v.loewis.de
Fri Jun 3 15:08:34 EDT 2005


Paul Rubin wrote:
> Any suggestions for the cleanest way to get rid of the thread?

As Jeff explains, it is rather unlikely that GC will collect
primegen objects, since the generating thread holds self as
a local variable.

You should make background_generator have explicit q and
event arguments, and you should signal the event in __del__.
However, this won't terminate the thread, since it still
hangs in .put. So it might be easiest to .read() in __del__
first.

Regards,
Martin



More information about the Python-list mailing list