1
0
forked from bot/app

新增线程安全共享内存储存器(注释)

This commit is contained in:
远野千束 2024-08-16 21:44:27 +08:00
parent 1b692dd13f
commit ff585ac7c2

View File

@ -4,16 +4,19 @@
"""
import threading
from typing import Any, Optional
from typing import Optional
from liteyuki.utils import IS_MAIN_PROCESS
from liteyuki.comm.channel import Channel
from liteyuki.utils import IS_MAIN_PROCESS
if IS_MAIN_PROCESS:
_locks = {}
def _get_lock(key):
def _get_lock(key) -> threading.Lock:
"""
获取锁
"""
if IS_MAIN_PROCESS:
if key not in _locks:
_locks[key] = threading.Lock()