I am running a multi threaded python program in command-prompt which continuously fetches stocks data from data source. However sometimes the program gets hung anywhere in code. When I press some key on keyboard it resumes again.
import threading
import time
def check_program_status():
while True:
print("Program is running...")
time.sleep(300)
def fetch_stocks_data():
pass
status_thread = threading.Thread(target=check_program_status)
status_thread.daemon = True
status_thread.start()
while True:
try:
fetch_stocks_data()
except Exception as e:
print(e)
To counter this problem I am printing few lines after 5 minute interval to see if program is running or not. But its not possible for me to monitor the program all the time. Is there any other solution to this.