Mypy: Got passing on macos (#34591)

* Mypy: Got mypy passing on macos

* common/realtime.py refactor

* Mypy: mypy passing on darwin

* Refactor: Removed else: pass statement

* Refactor: Removed unnecessary check

* added xattr to pyproject

* loggerd: switched to xatter module

* loggerd: removed unused module in xattr_cache.py

* UV: update uv.lock

* Update system/athena/athenad.py

Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>

* athenad: fixed blank lines

* loggerd: refactor of xattr_cache

* cleanup

---------

Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
pull/34592/head
BrainLess 2 months ago committed by GitHub
parent 917b45afd0
commit b09b48130e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      common/realtime.py
  2. 1
      pyproject.toml
  3. 7
      system/athena/athenad.py
  4. 7
      system/loggerd/xattr_cache.py
  5. 1131
      uv.lock

@ -1,6 +1,7 @@
"""Utilities for reading real time clocks and keeping soft real time constraints.""" """Utilities for reading real time clocks and keeping soft real time constraints."""
import gc import gc
import os import os
import sys
import time import time
from collections import deque from collections import deque
@ -28,13 +29,13 @@ class Priority:
def set_core_affinity(cores: list[int]) -> None: def set_core_affinity(cores: list[int]) -> None:
if not PC: if sys.platform == 'linux' and not PC:
os.sched_setaffinity(0, cores) os.sched_setaffinity(0, cores)
def config_realtime_process(cores: int | list[int], priority: int) -> None: def config_realtime_process(cores: int | list[int], priority: int) -> None:
gc.disable() gc.disable()
if not PC: if sys.platform == 'linux' and not PC:
os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(priority)) os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(priority))
c = cores if isinstance(cores, list) else [cores, ] c = cores if isinstance(cores, list) else [cores, ]
set_core_affinity(c) set_core_affinity(c)

@ -64,6 +64,7 @@ dependencies = [
"psutil", "psutil",
"pycryptodome", # used in updated/casync, panda, body, and a test "pycryptodome", # used in updated/casync, panda, body, and a test
"setproctitle", "setproctitle",
"xattr",
# logreader # logreader
"zstandard", "zstandard",

@ -765,8 +765,11 @@ def ws_manage(ws: WebSocket, end_event: threading.Event) -> None:
# While not sending data, onroad, we can expect to time out in 7 + (7 * 2) = 21s # While not sending data, onroad, we can expect to time out in 7 + (7 * 2) = 21s
# offroad, we can expect to time out in 30 + (10 * 3) = 60s # offroad, we can expect to time out in 30 + (10 * 3) = 60s
# FIXME: TCP_USER_TIMEOUT is effectively 2x for some reason (32s), so it's mostly unused # FIXME: TCP_USER_TIMEOUT is effectively 2x for some reason (32s), so it's mostly unused
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, 16000 if onroad else 0) if sys.platform == 'linux':
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 7 if onroad else 30) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, 16000 if onroad else 0)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 7 if onroad else 30)
elif sys.platform == 'darwin':
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPALIVE, 7 if onroad else 30)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 7 if onroad else 10) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 7 if onroad else 10)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 2 if onroad else 3) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 2 if onroad else 3)

@ -1,13 +1,14 @@
import os
import errno import errno
import xattr
_cached_attributes: dict[tuple, bytes | None] = {} _cached_attributes: dict[tuple, bytes | None] = {}
def getxattr(path: str, attr_name: str) -> bytes | None: def getxattr(path: str, attr_name: str) -> bytes | None:
key = (path, attr_name) key = (path, attr_name)
if key not in _cached_attributes: if key not in _cached_attributes:
try: try:
response = os.getxattr(path, attr_name) response = xattr.getxattr(path, attr_name)
except OSError as e: except OSError as e:
# ENODATA means attribute hasn't been set # ENODATA means attribute hasn't been set
if e.errno == errno.ENODATA: if e.errno == errno.ENODATA:
@ -19,4 +20,4 @@ def getxattr(path: str, attr_name: str) -> bytes | None:
def setxattr(path: str, attr_name: str, attr_value: bytes) -> None: def setxattr(path: str, attr_name: str, attr_value: bytes) -> None:
_cached_attributes.pop((path, attr_name), None) _cached_attributes.pop((path, attr_name), None)
return os.setxattr(path, attr_name, attr_value) xattr.setxattr(path, attr_name, attr_value)

1131
uv.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save