thread vs GC

"Martin v. Löwis" martin at
Fri Jun 3 21:08:34 CEST 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__


More information about the Python-list mailing list