2024-07-27 10:12:45 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
该模块用于轻雪主进程和Nonebot子进程之间的通信
|
2024-08-17 00:18:06 +08:00
|
|
|
依赖关系
|
|
|
|
event -> _
|
2024-08-19 23:47:39 +08:00
|
|
|
storage -> channel_
|
|
|
|
rpc -> channel_, storage
|
2024-07-27 10:12:45 +08:00
|
|
|
"""
|
2024-08-10 22:25:41 +08:00
|
|
|
from liteyuki.comm.channel import (
|
|
|
|
Channel,
|
|
|
|
get_channel,
|
|
|
|
set_channel,
|
|
|
|
set_channels,
|
2024-08-16 21:38:22 +08:00
|
|
|
get_channels,
|
|
|
|
active_channel,
|
|
|
|
passive_channel
|
2024-08-10 22:25:41 +08:00
|
|
|
)
|
2024-07-27 10:12:45 +08:00
|
|
|
from liteyuki.comm.event import Event
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
"Channel",
|
|
|
|
"Event",
|
2024-08-10 22:25:41 +08:00
|
|
|
"get_channel",
|
|
|
|
"set_channel",
|
|
|
|
"set_channels",
|
2024-08-16 21:38:22 +08:00
|
|
|
"get_channels",
|
|
|
|
"active_channel",
|
|
|
|
"passive_channel"
|
2024-07-27 10:12:45 +08:00
|
|
|
]
|
2024-08-16 21:38:22 +08:00
|
|
|
|
|
|
|
from liteyuki.utils import IS_MAIN_PROCESS
|
|
|
|
|
|
|
|
# 第一次引用必定为赋值
|
|
|
|
_ref_count = 0
|
|
|
|
if not IS_MAIN_PROCESS:
|
|
|
|
if (active_channel is None or passive_channel is None) and _ref_count > 0:
|
|
|
|
raise RuntimeError("Error: Channel not initialized in sub process")
|
|
|
|
_ref_count += 1
|