Stopping threads from the outside
Peter Hansen
peter at engcorp.com
Sun Mar 24 14:46:57 EST 2002
Boudewijn Rempt wrote:
>
> Peter Hansen wrote:
> > Yes, that's the case. It's generally considered to lead to
> > undefined behaviour if you do manage to kill a thread from
> > the outside, because of resource locking issues and such.
>
> That's the received opinion indeed. It still leads to problems.
> I mean -- it's why you can kill a process, but not a thread. But in
> an agent system, every agent (presumably running a thread, although
> I've implemented systems where agents share threads, cooperative
> multi-tasking agents) is on its own, and shouldn't own objects
> or locks.
I'm curious what the agent actually does if it doesn't share
anything. Does it not take input? And produce output?
No opening files, accessing Queues and such? If it does
any of those things, wouldn't that make it potentially a
problem if you killed it?
I realize it may be only a theoretical problem in some specific
applications, since one might be able to guarantee that one will
not attempt to kill a thread when it is in a particular subroutine
and therefore unsafe. It might be nice to have the option, if
one really wanted, especially if there are simple conditions
under which one could guarantee a thread is safe to kill (not
blocking and without shared resources locked).
-Peter
More information about the Python-list
mailing list