We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec1d988 commit 837a9edCopy full SHA for 837a9ed
common/watchdog.py
@@ -4,20 +4,19 @@
4
from openpilot.system.hardware.hw import Paths
5
6
WATCHDOG_FN = f"{Paths.shm_path()}/wd_"
7
-
+_LAST_KICK = 0.0
8
9
def kick_watchdog():
10
+ global _LAST_KICK
11
current_time = time.time()
- if not hasattr(kick_watchdog, 'last_kick'):
12
- kick_watchdog.last_kick = 0
13
14
- if current_time - kick_watchdog.last_kick < 1.0:
+ if current_time - _LAST_KICK < 1.0:
15
return
16
17
try:
18
with open(f"{WATCHDOG_FN}{os.getpid()}", 'wb') as f:
19
f.write(struct.pack('<Q', int(current_time * 1e9)))
20
f.flush()
21
- kick_watchdog.last_kick = current_time
+ _LAST_KICK = current_time
22
except OSError:
23
pass
0 commit comments