Skip to content

Commit 0640414

Browse files
Fixed test suite
1 parent 4de8327 commit 0640414

6 files changed

Lines changed: 37 additions & 329 deletions

File tree

data/models/debug/device_144_device_times.json

Lines changed: 0 additions & 158 deletions
This file was deleted.

data/models/debug/device_144_edge_times.json

Lines changed: 0 additions & 158 deletions
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ where = ["src"]
6060
pythonpath = [
6161
"src"
6262
]
63+
testpaths = [
64+
"tests"
65+
]
6366

6467
# Setuptools git versioning configuration
6568
[tool.setuptools-git-versioning]

src/server/communication/http_server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)