中断训练
This commit is contained in:
parent
b79a0a1b5b
commit
bb163578d6
@ -7,38 +7,27 @@
|
||||
@Desc:
|
||||
|
||||
"""
|
||||
import multiprocessing
|
||||
|
||||
import json
|
||||
from app.utils.redis_config import redis_client
|
||||
|
||||
|
||||
def _init(): # 初始化
|
||||
# 中断标志
|
||||
global _global_dict
|
||||
_global_dict = {}
|
||||
dict = {}
|
||||
redis_client.get_redis().set("_global_dict", json.dumps(dict))
|
||||
|
||||
# # ws列表存储
|
||||
# global _active_connections
|
||||
# _active_connections = multiprocessing.Manager().list()
|
||||
|
||||
# # ws字典存储
|
||||
# global _active_connections_dist
|
||||
# _active_connections_dist = multiprocessing.Manager().dict()
|
||||
|
||||
|
||||
# def get_active_connections():
|
||||
# return _active_connections
|
||||
|
||||
# def get_active_connections_dist():
|
||||
# return _active_connections_dist
|
||||
|
||||
def set_value(key, value):
|
||||
# 定义一个全局变量
|
||||
_global_dict[key] = value
|
||||
dict = redis_client.get_redis().get("_global_dict")
|
||||
if dict is None:
|
||||
dict = {}
|
||||
dict[key] = value
|
||||
redis_client.get_redis().set("_global_dict", json.dumps(dict))
|
||||
|
||||
|
||||
def get_value(key):
|
||||
# 获得一个全局变量,不存在则提示读取对应变量失败
|
||||
try:
|
||||
return _global_dict[key]
|
||||
return redis_client.get_redis().get("_global_dict")[key]
|
||||
except:
|
||||
print('读取' + key + '失败\r\n')
|
||||
|
Loading…
x
Reference in New Issue
Block a user