steam-server/app/services/stream_manager.py

18 lines
407 B
Python
Raw Permalink Normal View History

2024-12-13 18:21:25 +08:00
from app.utils.logger import get_logger
2024-12-12 20:04:36 +08:00
import time
stream_manager = {}
2024-12-13 18:21:25 +08:00
logger = get_logger(__name__)
2024-12-12 20:04:36 +08:00
def stop_stream(stream_id: str):
2024-12-13 18:21:25 +08:00
if stream_id in stream_manager:
process = stream_manager[stream_id]["process"]
2024-12-12 20:04:36 +08:00
process.terminate()
2024-12-13 18:21:25 +08:00
process.wait() # 确保进程已经完全终止
logger.info(f"Stream {stream_id} stopped.")
del stream_manager[stream_id]
2024-12-17 20:07:29 +08:00