RODY/app/configs/global_var.py
2022-11-24 10:56:11 +08:00

45 lines
895 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
@Time 2022/11/15 10:13
@Auth
@File global_var.py
@IDE PyCharm
@MottoABC(Always Be Coding)
@Desc
"""
import multiprocessing
def _init(): # 初始化
# 中断标志
global _global_dict
_global_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
def get_value(key):
# 获得一个全局变量,不存在则提示读取对应变量失败
try:
return _global_dict[key]
except:
print('读取' + key + '失败\r\n')