from collections.abc import Iterable from fastapi import BackgroundTasks from app.ws.hub import hub def notify(background: BackgroundTasks, user_ids: Iterable[int], event: str, data: dict) -> None: """Tell all devices of these users about a change, after the response is sent.""" for user_id in set(user_ids): background.add_task(hub.broadcast, user_id, {"type": event, "data": data})