refactor: replace threading with multiprocessing
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 10s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 2m52s
Build Worker Base and Application Images / deploy-stack (push) Successful in 8s
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 10s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 2m52s
Build Worker Base and Application Images / deploy-stack (push) Successful in 8s
This commit is contained in:
parent
e87ed4c056
commit
bfab574058
6 changed files with 682 additions and 58 deletions
15
app.py
15
app.py
|
@ -4,12 +4,20 @@ Refactored modular architecture for computer vision pipeline processing.
|
|||
"""
|
||||
import json
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
import os
|
||||
import time
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI, WebSocket, HTTPException, Request
|
||||
from fastapi.responses import Response
|
||||
|
||||
# Set multiprocessing start method to 'spawn' for uvicorn compatibility
|
||||
if __name__ != "__main__": # When imported by uvicorn
|
||||
try:
|
||||
mp.set_start_method('spawn', force=True)
|
||||
except RuntimeError:
|
||||
pass # Already set
|
||||
|
||||
# Import new modular communication system
|
||||
from core.communication.websocket import websocket_endpoint
|
||||
from core.communication.state import worker_state
|
||||
|
@ -85,10 +93,9 @@ else:
|
|||
os.makedirs("models", exist_ok=True)
|
||||
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)}")
|
||||
# Stream manager is already initialized with multiprocessing in manager.py
|
||||
# (shared_stream_manager is created with max_streams=20 from config)
|
||||
logger.info(f"Using pre-configured stream manager with max_streams={config.get('max_streams', 20)}")
|
||||
|
||||
# Store cached frames for REST API access (temporary storage)
|
||||
latest_frames = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue