perf(douyu): 拆分任务槽并改造绑定扫码调度
This commit is contained in:
@@ -9,7 +9,7 @@ import asyncio
|
||||
import os
|
||||
import threading
|
||||
|
||||
from web.backend.database import SessionLocal
|
||||
from web.backend.database import WorkerSessionLocal
|
||||
|
||||
from .douyu_concurrency import clamp_batch_task_concurrency
|
||||
from .douyu_runner import DouyuBatchRunner, douyu_batch_registry
|
||||
@@ -39,10 +39,15 @@ def start_douyu_batch(
|
||||
loop: asyncio.AbstractEventLoop | None = None,
|
||||
log_queue: asyncio.Queue | None = None,
|
||||
) -> None:
|
||||
"""创建执行线程;从工作线程调用时必须显式传入主事件循环和日志队列。"""
|
||||
loop = loop or asyncio.get_running_loop()
|
||||
log_queue = log_queue or asyncio.Queue()
|
||||
thread_db = SessionLocal()
|
||||
"""Create the batch coordinator; websocket logging is optional."""
|
||||
if loop is None:
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
loop = None
|
||||
if log_queue is None and loop is not None:
|
||||
log_queue = asyncio.Queue()
|
||||
thread_db = WorkerSessionLocal()
|
||||
runner = DouyuBatchRunner(
|
||||
db=thread_db,
|
||||
batch_id=batch_id,
|
||||
|
||||
Reference in New Issue
Block a user