1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-12 09:48:20 +08:00

Pref: Release rpc connection on idle so OCR can be load balanced

This commit is contained in:
LmeSzinc
2024-05-09 02:57:45 +08:00
parent c47c5b3bd1
commit 28b452164f
2 changed files with 22 additions and 2 deletions

View File

@@ -91,7 +91,15 @@ def release_resources(next_task=''):
# Usually to have 2 models loaded and each model takes about 20MB
# This will release 20-40MB
from module.webui.setting import State
if not State.deploy_config.UseOcrServer:
if State.deploy_config.UseOcrServer:
if not next_task:
# Disconnect OCR server on idle
from module.ocr.ocr import OCR_MODEL
try:
OCR_MODEL.close()
except AttributeError:
pass
else:
# Release only when using per-instance OCR
from module.ocr.ocr import OCR_MODEL
if 'Opsi' in next_task or 'commission' in next_task: