How to force a thread to stop
Carl J. Van Arsdall
cvanarsdall at mvista.com
Wed Jul 26 12:41:24 EDT 2006
bryanjugglercryptographer at yahoo.com wrote:
> Carl J. Van Arsdall wrote:
>
> I don't get what threading and Twisted would to do for
> you. The problem you actually have is that you sometimes
> need terminate these other process running other programs.
> Use spawn, fork/exec* or maybe one of the popens.
>
>
>
I have a strong need for shared memory space in a large distributed
environment. How does spawn, fork/exec allow me to meet that need?
I'll look into it, but I was under the impression having shared memory
in this situation would be pretty hairy. For example, I could fork of a
50 child processes, but then I would have to setup some kind of
communication mechanism between them where the server builds up a queue
of requests from child processes and then services them in a FIFO
fashion, does that sound about right?
> Threads have little to do with what you say you need.
>
> [...]
>
>> I feel like this is something we've established multiple times. Yes, we
>> want the thread to kill itself. Alright, now that we agree on that,
>> what is the best way to do that.
>>
>
> Wrong. In your examples, you want to kill other processes. You
> can't run external programs such as ssh as Python threads. Ending
> a Python thread has essentially nothing to do with it.
>
There's more going on than ssh here. Since I want to run multiple
processes to multiple devices at one time and still have mass shared
memory I need to use threads. There's a mass distributed system that
needs to be controlled, that's the problem I'm trying to solve. You can
think of each ssh as a lengthy IO process that each gets its own
device. I use the threads to allow me to do IO to multiple devices at
once, ssh just happens to be the IO. The combination of threads and ssh
allowed us to have a *primitive* distributed system (and it works too,
so I *can* run external programs in python threads). I didn't say is
was the best or the correct solution, but it works and its what I was
handed when I was thrown into this project. I'm hoping in fifteen years
or when I get an army of monkeys to fix it, it will change. I'm not
worried about killing processes, that's easy, I could kill all the sshs
or whatever else I want without batting an eye. The threads that were
created in order to allow me to do all of this work simultaneously,
that's the issue. Granted, I'm heavily looking into a way of doing this
with processes, I still don't see how threads are the wrong choice with
my present situation.
>
> Not me. I'm saying work the problem you actually have.
>
The problem I have is a large distributed system, that's the reality of
it. The short summary, I need to use and control 100+ machines in a
computing farm. They all need to share memory or to actively
communicate with each other via some other mechanism. Without giving
any other details, that's the problem I have to solve. Right now I'm
working with someone else's code. Without redesigning the system from
the ground up, I have to fix it.
--
Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software
More information about the Python-list
mailing list