File size: 440 Bytes
23ecb5d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import threading
from collections import defaultdict
from typing import Tuple
_lock = threading.Lock()
_default = (0.5, 0.5)
_mood_store: defaultdict[str, Tuple[float, float]] = defaultdict(lambda: _default)
def get_mood(client_id: str) -> Tuple[float, float]:
with _lock: return _mood_store[client_id]
def set_mood(client_id: str, valence: float, arousal: float) -> None:
with _lock: _mood_store[client_id] = (valence, arousal)
|