I want to print the output of each thread on different files. This is my code for threads :-
def __init__(self, command):
threading.Thread.__init__(self)
self.command = command
def run(self):
call(self.command)
def get_devices():
command_res = 'adb devices'
results = os.popen(command_res, "r")
command_result = ''
while 1:
line = results.readline()
if not line: break
command_result += line
devices = command_result.partition('\n')[2].replace('n','').split('\tdevice')
return [device for device in devices if len(device) > 2]
for device_id in device_ids :
threads.append(Universal([sys.argv[1], device_id]))
for thread in threads:
try:
thread.start();
except:
print("Error: unable to start thread")
for thread in threads:
thread.join();
Here device_ids is the list of my devices attached. Each device runs on separate thread. Is there a solution to do this in Python. Thanks in Advance