is it safe to stop a thread?
Tim Peters
tim.one at home.com
Wed May 23 01:49:05 EDT 2001
[Dustin Boswell]
> ...
> there should be some "safe" mechanism set up for threads to signal
> each other.
Since Python uses each platform's native notion of threads, it's restricted
to what native platform threads support. Python isn't an operating system.
That is, Python doesn't *implement* threads. Instead it wraps a portable API
*around* platform threads. It's unusual to see reliable ways for one thread
to kill another; even Java (eventually) gave up on that.
> But why is it safe to stop a process?
Primarily because an OS saves enough information about processes and their
relation to system resource state to make it *possible* to clean up after
killed processes safely. Thread packages typically do not save enough info
about threads and their use of system resrouces to do the same; in return,
because threads aren't bogged down with so much hidden recovery state,
they're typically nimbler than processes. The things that make threads
lightweight are the baggage they *don't* carry.
> ...
> It seems like I'm being forced to do multiple processes and
> interprocess-communication, which seems dumb, cause threading
> seems like a better solution...
If method A has cool feature X and method B has cool feature Y, it's not
always the case that the lack of a method C combining and X and Y (and
without introducing new drawbacks) is simply due to a dumb universe picking
on you <wink>.
although-that's-always-my-first-guess-too-ly y'rs - tim
More information about the Python-list
mailing list