@@ -63,6 +63,11 @@ def __init__(
6363 self .start_timestamp = self ._get_current_time ()
6464 self ._setup_routes ()
6565
66+ def _schedule_resync_ntp (self ):
67+ timer = threading .Timer (600 , self ._resync_ntp )
68+ timer .daemon = True
69+ timer .start ()
70+
6671 def _sync_with_ntp (self ) -> float :
6772 """Synchronize with NTP server at startup with exponential backoff.
6873
@@ -77,7 +82,7 @@ def _sync_with_ntp(self) -> float:
7782 response = self .ntp_client .request (self .ntp_server )
7883 offset = response .offset
7984 # Schedule periodic re-sync (every 10 minutes)
80- threading . Timer ( 600 , self ._resync_ntp ). start ()
85+ self ._schedule_resync_ntp ()
8186 return offset
8287 except ntplib .NTPException :
8388 logger .warning (
@@ -91,7 +96,7 @@ def _sync_with_ntp(self) -> float:
9196 "NTP sync failed after all retries -- falling back to offset=0.0"
9297 )
9398 # Still schedule periodic re-sync so we recover later
94- threading . Timer ( 600 , self ._resync_ntp ). start ()
99+ self ._schedule_resync_ntp ()
95100 return 0.0
96101
97102 def _resync_ntp (self ):
@@ -102,7 +107,7 @@ def _resync_ntp(self):
102107 except Exception as e :
103108 logger .warning (f"NTP re-sync failed: { e } " )
104109 # Schedule next re-sync regardless of success/failure
105- threading . Timer ( 600 , self ._resync_ntp ). start ()
110+ self ._schedule_resync_ntp ()
106111
107112 def _get_current_time (self ) -> float :
108113 return time .time () + self .offset
0 commit comments