Stopping a thread from the calling process
Gordon McMillan
gmcm at hypernet.com
Sun Jan 16 13:21:41 EST 2000
Scott Barron asks:
> is there an easy and fairly portable way of doing this?
If you mean "interrupting" or "killing", no. WIth good reason.
OS level threads are often "light weight" processes. Generally
what's been trimmed is all the stuff dealing with reclaming
resources, releasing locks etc. on thread death. So if you
"kill" a thread, you're likely to be leaving your process in an
indeterminate state.
The normal idiom is to ask politely - have the thread
periodically check some variable to see if it should stop.
- Gordon
More information about the Python-list
mailing list