From 94d5820fbf7434708853533255cac854ab9a51f0 Mon Sep 17 00:00:00 2001 From: quadseed Date: Sun, 18 Feb 2024 14:17:08 +0900 Subject: [PATCH] Update: [Backend] Tasks that were being handled in multi-processes are changed to run in multi-threading --- backend/src/main.py | 4 ++-- backend/src/stream.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main.py b/backend/src/main.py index 6af1da0..a38df78 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -2,7 +2,7 @@ import logging import os import pathlib -from concurrent.futures import ProcessPoolExecutor +from concurrent.futures import ThreadPoolExecutor import dotenv import uvicorn @@ -32,7 +32,7 @@ def main(): utils.create_temp_directory() Base.metadata.create_all(engine) - with ProcessPoolExecutor() as executor: + with ThreadPoolExecutor() as executor: executor.submit(start_api_server) if os.environ.get("AUTO_RECORDING").lower() in ('true', 'enable', 'on'): executor.submit(start_websocket_client) diff --git a/backend/src/stream.py b/backend/src/stream.py index ac64ccf..9122e7b 100644 --- a/backend/src/stream.py +++ b/backend/src/stream.py @@ -1,4 +1,4 @@ -from concurrent.futures import ProcessPoolExecutor +from concurrent.futures import ThreadPoolExecutor from multiprocessing import Manager from parallel import stream_video, start_stream_comments @@ -7,7 +7,7 @@ class StreamManager: def __init__(self): - self.executor = ProcessPoolExecutor(max_workers=256) + self.executor = ThreadPoolExecutor(max_workers=64) self.events = {} self.manager = Manager()