mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor(lifecycle): enhance shutdown support for event and mediaserver
This commit is contained in:
@@ -3,6 +3,7 @@ from typing import List, Union, Optional, Generator
|
|||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
from app.chain import ChainBase
|
from app.chain import ChainBase
|
||||||
|
from app.core.config import global_vars
|
||||||
from app.db.mediaserver_oper import MediaServerOper
|
from app.db.mediaserver_oper import MediaServerOper
|
||||||
from app.helper.service import ServiceConfigHelper
|
from app.helper.service import ServiceConfigHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
@@ -134,6 +135,8 @@ class MediaServerChain(ChainBase):
|
|||||||
logger.info(f"正在同步 {server_name} 媒体库 {library.name} ...")
|
logger.info(f"正在同步 {server_name} 媒体库 {library.name} ...")
|
||||||
library_count = 0
|
library_count = 0
|
||||||
for item in self.items(server=server_name, library_id=library.id):
|
for item in self.items(server=server_name, library_id=library.id):
|
||||||
|
if global_vars.is_system_stopped:
|
||||||
|
return
|
||||||
if not item or not item.item_id:
|
if not item or not item.item_id:
|
||||||
continue
|
continue
|
||||||
logger.debug(f"正在同步 {item.title} ...")
|
logger.debug(f"正在同步 {item.title} ...")
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ from app.utils.singleton import Singleton
|
|||||||
DEFAULT_EVENT_PRIORITY = 10 # 事件的默认优先级
|
DEFAULT_EVENT_PRIORITY = 10 # 事件的默认优先级
|
||||||
MIN_EVENT_CONSUMER_THREADS = 1 # 最小事件消费者线程数
|
MIN_EVENT_CONSUMER_THREADS = 1 # 最小事件消费者线程数
|
||||||
INITIAL_EVENT_QUEUE_IDLE_TIMEOUT_SECONDS = 1 # 事件队列空闲时的初始超时时间(秒)
|
INITIAL_EVENT_QUEUE_IDLE_TIMEOUT_SECONDS = 1 # 事件队列空闲时的初始超时时间(秒)
|
||||||
MAX_EVENT_QUEUE_IDLE_TIMEOUT_SECONDS = 60 # 事件队列空闲时的最大超时时间(秒)
|
MAX_EVENT_QUEUE_IDLE_TIMEOUT_SECONDS = 5 # 事件队列空闲时的最大超时时间(秒)
|
||||||
|
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
|
|||||||
Reference in New Issue
Block a user