Making a multithread app that runs several instances of whatever the app did before

Steve Holden steve at holdenweb.com
Tue Aug 15 06:17:54 EDT 2006


olbion at gmail.com wrote:
> Hi
> 
> I've aquired a program written in Python, and without much knowledge of
> the language I'm trying to make some changes to it. The original
> program starts, runs a certain process and then finishes. I want to
> adapt it so that, at a certain stage of the process, a new process is
> started from scratch, running at the same time as the original one.
> When the original one is finished, it should exit without causing the
> newer process to stop.
> 
> I've successfully achieved this using sys.popen methods to start
> separate processes, but come to realise that running seperate processes
> is not a very good solution, since it uses up more memory and becomes
> harder to manage. I'd like the same thing to be achieved using threads.
> 
> I've come as far as being able to start the program which runs the
> first thread. My problem arrises when I want the new thread to be
> started. It seems that if I do this by calling a function from within
> the thread, I'm unable to stop the original thread whenever that
> finishes. I imagine that what I've achieved is something like:
> 
> Start file (eg start.py) starts Thread 1
> Thread 1 starts a new thread (Thread 2) and becomes the parent of that
> thread
> Thread 2 starts a new thread (Thread 3)... and so on
> 
> I think that what I want is something like:
> 
> Start file starts Thread 1
> Thread 1 informs start file that a new thread should be started; start
> file starts Thread 2
> .... and so on
> 
> So, if my thinking so far is correct, how can a thread cause another
> thread to be started without becoming its parent?
> 
Read up on "demonised" (sp?) threads in the documentation from threading.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list