mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-13 14:27:26 +08:00
🐛 [channel]: 暂停通道接收功能
This commit is contained in:
parent
8510b0ed3f
commit
ae18bfaee1
@ -191,22 +191,6 @@ class Channel(Generic[T]):
|
|||||||
else:
|
else:
|
||||||
[asyncio.create_task(_callback_funcs[func_id](data)) for func_id in self._on_sub_receive_func_ids]
|
[asyncio.create_task(_callback_funcs[func_id](data)) for func_id in self._on_sub_receive_func_ids]
|
||||||
|
|
||||||
async def start_receive_loop(self):
|
|
||||||
"""
|
|
||||||
@litedoc-hide
|
|
||||||
开始接收数据
|
|
||||||
会自动判断主进程和子进程,需要在对应进程都调度一次
|
|
||||||
"""
|
|
||||||
if len(self._on_main_receive_func_ids) == 0:
|
|
||||||
logger.warning(f"No on_receive function registered for {self.name}")
|
|
||||||
return
|
|
||||||
|
|
||||||
self.is_receive_loop_running = True
|
|
||||||
logger.debug(f"Starting receive loop for {self.name}")
|
|
||||||
while not self._closed:
|
|
||||||
data = await self.async_receive()
|
|
||||||
await self._run_on_receive_funcs(data)
|
|
||||||
|
|
||||||
|
|
||||||
"""子进程可用的主动和被动通道"""
|
"""子进程可用的主动和被动通道"""
|
||||||
active_channel: Channel = Channel(name="active_channel") # 主动通道
|
active_channel: Channel = Channel(name="active_channel") # 主动通道
|
||||||
|
@ -132,8 +132,6 @@ class ProcessManager:
|
|||||||
"""
|
"""
|
||||||
对外启动方法,启动所有进程,创建asyncio task
|
对外启动方法,启动所有进程,创建asyncio task
|
||||||
"""
|
"""
|
||||||
[asyncio.create_task(chan.start_receive_loop()) for chan in get_channels().values()]
|
|
||||||
[asyncio.create_task(sm.start_receive_loop()) for sm in [shared_memory]]
|
|
||||||
[asyncio.create_task(self._run_process(name)) for name in self.targets]
|
[asyncio.create_task(self._run_process(name)) for name in self.targets]
|
||||||
|
|
||||||
def add_target(self, name: str, target: TARGET_FUNC, args: tuple = (), kwargs=None):
|
def add_target(self, name: str, target: TARGET_FUNC, args: tuple = (), kwargs=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user