I have the following python code in main which runs my program each 5 seconds
def main():
while True:
now = datetime.strptime((datetime.now().strftime("%H:%M")), "%H:%M")
if datetime.strptime('23:59', "%H:%M") > now > datetime.strptime('07:30', "%H:%M"):
start_time = time.time()
while execute_data():
time.sleep(5.0 - ((time.time() - start_time) % 5.0))
execute_data():
function once in 40 minutes does a job which takes a lot of time (nearly 3 min) when it finished its job my program goes crazy and runs once in every half second for example.
How can I solve this?