Merge pull request #358 from dinakars777/fix/openclaw-poll-clock-init

fix: initialize OpenClaw poll timing once
This commit is contained in:
Trevin Chow
2026-05-16 23:41:42 -07:00
committed by GitHub
2 changed files with 7 additions and 6 deletions
@@ -335,8 +335,9 @@ def poll_device_auth(
""" """
import sys import sys
deadline = time.time() + timeout started_at = time.time()
last_reminder = time.time() deadline = started_at + timeout
last_reminder = started_at
reminder_count = 0 reminder_count = 0
max_reminders = 4 max_reminders = 4
reminder_interval = 30 # seconds between reminders reminder_interval = 30 # seconds between reminders
+4 -4
View File
@@ -213,10 +213,10 @@ class TestPollDeviceAuth:
@patch("lib.setup_wizard.urlopen") @patch("lib.setup_wizard.urlopen")
def test_timeout_returns_none(self, mock_urlopen, mock_time): def test_timeout_returns_none(self, mock_urlopen, mock_time):
"""Returns None when timeout is exceeded.""" """Returns None when timeout is exceeded."""
# poll_device_auth calls time.time() for deadline init, last_reminder init, # poll_device_auth captures started_at once, derives deadline + last_reminder
# then once per while-loop iteration. Three values are enough for one check # from it, then checks time.time() in the while-loop. Two values: started_at,
# that exceeds the deadline. # then a value past the deadline so the loop exits immediately.
mock_time.time = MagicMock(side_effect=[0, 0, 301]) mock_time.time = MagicMock(side_effect=[0, 301])
mock_time.sleep = MagicMock() mock_time.sleep = MagicMock()
result = setup_wizard.poll_device_auth("dc-123", interval=5, timeout=300) result = setup_wizard.poll_device_auth("dc-123", interval=5, timeout=300)