[ad_1]
I am trying to redirect the stdout from another python file to a logfile and the output from the file is continuous and it is something we call an infinite loop, I need to hold the redirection for a while and continue it again.
Meanwhile, I will use the Logfile which I have been redirecting the data to do some analysis of the logs
I also need to launch the python script multiple times for load testing, using multi threading here
code gets locked / will be stopped at “os.system(“python Test.py >> Stream.log”)”
because the redirection is continous
I need to stop the redirection for some time and use the data in stream.log and start the previous thread again(let it continue from where it stopped) and also initiate new threads
def Pusher(Num):
try :
with open(filename,"r") as f:
f.close()
except FileNotFoundError as fe :
return fe
else:
lock.acquire(blocking=True)
os.system("python Test.py >> Stream.log")
data_check()
time.sleep(10)
lock.release()
print(file_check())
threads = []
for i in range(0,Number):
print("Invoking thread for {} time........".format(i))
t = threading.Thread(target=Pusher,args=str(i))
t.start()
threads.append(t)
time.sleep(30)
[ad_2]