feat: update max_streams
Some checks failed
Build Worker Base and Application Images / deploy-stack (push) Blocked by required conditions
Build Worker Base and Application Images / check-base-changes (push) Successful in 7s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Has been cancelled

This commit is contained in:
ziesorx 2025-09-25 03:11:22 +07:00
parent b8de5e191e
commit f467cb005d
4 changed files with 18 additions and 5 deletions

7
app.py
View file

@ -76,7 +76,7 @@ else:
"poll_interval_ms": 100, "poll_interval_ms": 100,
"reconnect_interval_sec": 5, "reconnect_interval_sec": 5,
"target_fps": 10, "target_fps": 10,
"max_streams": 5, "max_streams": 20,
"max_retries": 3 "max_retries": 3
} }
logger.warning(f"Configuration file {config_path} not found, using defaults") logger.warning(f"Configuration file {config_path} not found, using defaults")
@ -85,6 +85,11 @@ else:
os.makedirs("models", exist_ok=True) os.makedirs("models", exist_ok=True)
logger.info("Ensured models directory exists") logger.info("Ensured models directory exists")
# Initialize stream manager with config value
from core.streaming import initialize_stream_manager
initialize_stream_manager(max_streams=config.get('max_streams', 10))
logger.info(f"Initialized stream manager with max_streams={config.get('max_streams', 10)}")
# Store cached frames for REST API access (temporary storage) # Store cached frames for REST API access (temporary storage)
latest_frames = {} latest_frames = {}

View file

@ -1,6 +1,6 @@
{ {
"poll_interval_ms": 100, "poll_interval_ms": 100,
"max_streams": 5, "max_streams": 20,
"target_fps": 2, "target_fps": 2,
"reconnect_interval_sec": 5, "reconnect_interval_sec": 5,
"max_retries": -1 "max_retries": -1

View file

@ -4,7 +4,7 @@ Provides modular frame readers, buffers, and stream management.
""" """
from .readers import RTSPReader, HTTPSnapshotReader from .readers import RTSPReader, HTTPSnapshotReader
from .buffers import FrameBuffer, CacheBuffer, shared_frame_buffer, shared_cache_buffer from .buffers import FrameBuffer, CacheBuffer, shared_frame_buffer, shared_cache_buffer
from .manager import StreamManager, StreamConfig, SubscriptionInfo, shared_stream_manager from .manager import StreamManager, StreamConfig, SubscriptionInfo, shared_stream_manager, initialize_stream_manager
__all__ = [ __all__ = [
# Readers # Readers
@ -21,5 +21,6 @@ __all__ = [
'StreamManager', 'StreamManager',
'StreamConfig', 'StreamConfig',
'SubscriptionInfo', 'SubscriptionInfo',
'shared_stream_manager' 'shared_stream_manager',
'initialize_stream_manager'
] ]

View file

@ -458,4 +458,11 @@ class StreamManager:
# Global shared instance for application use # Global shared instance for application use
shared_stream_manager = StreamManager(max_streams=10) # Will be initialized with config value in app.py
shared_stream_manager = None
def initialize_stream_manager(max_streams: int = 10):
"""Initialize the global stream manager with config value."""
global shared_stream_manager
shared_stream_manager = StreamManager(max_streams=max_streams)
return shared_stream_manager