Question about turning off garbage collection

David Hirschfield davidh at ilm.com
Thu Oct 5 21:05:45 EDT 2006


Question from a post to pygtk list...but it probably would be better 
answered here:

I encountered a nasty problem with an external module conflicting with 
my python threads recently, and right now the only fix appears to be to 
turn off garbage collection while the critical code of the thread is 
running, and then turn it back on afterwards.

Now, I don't know much about how the garbage collector works in python, 
and in order to get the thread to run without freezing, I'm wrapping the 
threaded processing function with calls to gc.disable()/gc.enable().

So what's that going to do? Will calling gc.enable() put things in good 
shape? Will all objects created while the garbage collector was off now 
be un-collectable? I'm extremely wary of this solution, as I think 
anyone would be. I don't want a suddenly super-leaky app.

Comments? Suggestions? (I know, I know, avoid threads...if only I could)
-Dave

-- 
Presenting:
mediocre nebula.




More information about the Python-list mailing list