How to force a thread to stop

bryanjugglercryptographer at yahoo.com bryanjugglercryptographer at yahoo.com
Wed Jul 26 15:31:10 EDT 2006


Carl J. Van Arsdall wrote:
> 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.

Distributed shared memory is a tough trick; only a few systems simulate
it.

>  How does spawn, fork/exec allow me to meet that need?

I have no idea why you think threads or fork/exec will give you
distributed
shared memory.

> 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?

That much is easy. What it has to with what you say you require
remains a mystery.


> > 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.

No, you would need to use something that implements shared
memory across multiple devices. Threads are multiple lines of
execution in the same address space.

>  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).

No, you showed launching it from a Python thread using os.system().
It's not running in the thread; it's running in a separate process.

> 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.

After launching it with os.sytem()? Can you show the code?


-- 
--Bryan




More information about the Python-list mailing list