perf(douyu): 限制任务并发并释放长事务连接
This commit is contained in:
@@ -11,6 +11,7 @@ import threading
|
||||
|
||||
from web.backend.database import SessionLocal
|
||||
|
||||
from .douyu_concurrency import clamp_batch_task_concurrency
|
||||
from .douyu_runner import DouyuBatchRunner, douyu_batch_registry
|
||||
|
||||
|
||||
@@ -26,7 +27,7 @@ DOUYU_BATCH_CREATE_CONCURRENCY = _env_positive_int(
|
||||
"DOUYU_BATCH_CREATE_CONCURRENCY",
|
||||
2,
|
||||
)
|
||||
DOUYU_MAX_ACTIVE_BATCHES = _env_positive_int("DOUYU_MAX_ACTIVE_BATCHES", 20)
|
||||
DOUYU_MAX_ACTIVE_BATCHES = _env_positive_int("DOUYU_MAX_ACTIVE_BATCHES", 10)
|
||||
|
||||
|
||||
def start_douyu_batch(
|
||||
@@ -49,7 +50,7 @@ def start_douyu_batch(
|
||||
payload=payload,
|
||||
log_queue=log_queue,
|
||||
loop=loop,
|
||||
concurrency=max(1, min(int(concurrency), 10)),
|
||||
concurrency=clamp_batch_task_concurrency(concurrency),
|
||||
)
|
||||
douyu_batch_registry.register(batch_id, log_queue, loop, runner)
|
||||
threading.Thread(target=runner.run, daemon=True).start()
|
||||
|
||||
Reference in New Issue
Block a user