I have a python program that has several classes that when called invoke additional threads. These threads each call a separate python script to do stuff.
I followed the recommendations suggested in the question posted on "Python threading inside a class" and created the class to call the separate threads.
Below is a sample snippet of what I have.
class SomeThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
os.system('start Python_program_to_do_stuff.py')
I then instantiate several versions of this thread like this:
Some_Thread_1 = SomeThread()
Some_Thread_2 = SomeThread()
...
I set them to True
Some_Thread_1.setDaemon(True)
Some_Thread_2.setDaemon(True)
And then when actually invoking, I call each one independently
Some_Thread_1.start()
This opens a separate window to run 'Python_program_to_do_stuff.py'. Output from this program is stored at a predetermined location hard coded inside of it.
The current python program works well, but now I want to pass a very specific parameter to the class every time that it is invoked so the output data is stored in a specific location for that call. So for example, the first time I call class 'SomeThread' (ie executing Some_Thread_1.start()), store the output at location A, second time store at location B, etc. This location is not fixed and it depends on the test that I am running.
I imagine, following the reference above, that I could do something like this:
class SomeThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self, path_for_output_data):
self.path_for_output_data = path_for_output_data
os.system('start Python_program_to_do_stuff.py', path_for_output_data)
and then when invoking:
Some_Thread_1.start("c:/data")
but I am getting an error: "start() takes exactly 1 argument (2 given) ".
Tips are appreciated.
{As as side note, I am exploring the use of subprocess.Popen() instead of os.system(), but that is a separate mess).
