Files
facefusion/facefusion/rtc_store.py
T
Harisreedhar 4fe79483ea Fix stream lifecycle bugs: threading, RTP sync, and resource cleanup (#1125)
* fix executor thread not terminating after stream deletion

* fix stream shutdown and thread lifecycle

* add todo

* cleanup

* cleanup

* cleanup

* cleanup

* audio_queue.put() → get_nowait() + put_nowait()

* rename test

* fix test

* merge tests

* cleanup tests

* cleanup tests

* cleanup tests

* simplify test logic with mock

* cleanup

* cleanup hard to read stream_helper.py

* introduce rtc_peer.has_peers

* fix lint

* add todos

* fix test hash
2026-05-22 16:29:45 +05:30

34 lines
646 B
Python

from typing import List
from facefusion import rtc
from facefusion.types import RtcPeer, RtcStore, SessionId
RTC_STORE : RtcStore = {}
def init_peers(session_id : SessionId) -> None:
RTC_STORE[session_id] = []
def get_peers(session_id : SessionId) -> List[RtcPeer]:
return RTC_STORE.get(session_id)
def delete_peers(session_id : SessionId) -> None:
if session_id in RTC_STORE:
rtc_peers = get_peers(session_id)
if rtc_peers:
rtc.delete_peers(rtc_peers)
del RTC_STORE[session_id]
return None
def has_peers(session_id : SessionId) -> bool:
return bool(RTC_STORE.get(session_id))
def clear() -> None:
RTC_STORE.clear()