Handling threads

Blair Hall b.hall at irl.cri.nz
Wed Aug 7 07:09:28 CEST 2002

I have a problem with a class that uses the Thread module and starts a
background thread
when an object is created to do some misc stuff.

My class has a 'close' method that terminates the background thread.

However, the class __del__(), which calls close(), does not seem to be a
way of shutting down the thread. Actually, it is not the fault of
__del__(), it is
the fact that you do not seem to be able to rely on __del__() being
when an object is not needed any more.

In my case, I find that even quiting the PythonWin environement is not
enough to properly
end the running process. I need to do Ctrl-Alt-Delete and end the
PythonWin task (Windows95).

Is there not a 'better' way to make my class easy to use ( it is very
easy to forget to call close()! )?

More information about the Python-list mailing list