1import datetime as DT
2import time
3
4while True:
5 now = DT.datetime.now()
6 target = DT.datetime.combine(DT.date.today(), DT.time(hour=8))
7 if target < now:
8 target += DT.timedelta(days=1)
9
10 time.sleep((target-now).total_seconds())
11 # do something