I wrote a script which fetchs stock prices, cleans it and stores it in excel file. below code is an example
def fetchprice();
#fetchs stock price
#cleans it
while True;
fetchprice()
time.sleep(300)
so i right now i am making it sleep for 5 minutes to run every 5 minutes but the problem is when the function runs it takes some seconds to complete the task and after sleeping for 5 minutes instead of running at 9:30 am it runs at 9:30:08 am adding seconds from the function time.
is there any way i can run the task exactly after 5 minutes for example: if i start at 9:30 next it should be at 9:35, 9:40, 9:45 not matter how many seconds the function takes.