473,387 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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?

Aug 15 '06 #1
1 1379
ol****@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

Aug 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
3
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and...
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
0
by: fred | last post by:
I need some help in trying to understand how to make myCollection (inherited from CollectionBase) multithread safe. Taking my implementation of the Add Sub and a readonly property Item. Public...
90
by: Ben Finney | last post by:
Howdy all, How can a (user-defined) class ensure that its instances are immutable, like an int or a tuple, without inheriting from those types? What caveats should be observed in making...
10
by: Derek Hart | last post by:
On the main thread I have a status bar in a Windows form that I want to update when a long database process runs. The database process runs on a separate thread: Dim t As New...
0
by: Gordon Cone | last post by:
I am currently debugging a deadlock in a multithread C# application. It makes lots of calls to legacy unmanaged code. The application runs on windows sever 2003 and uses the sever version of the...
0
by: Gordon Cone | last post by:
I am currently debugging a deadlock in a multithread C# application. It makes lots of calls to legacy unmanaged code. The application runs on windows sever 2003 and uses the sever version of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.