1
0
forked from bot/app

🐛 [channel]: 暂停通道接收功能

This commit is contained in:
远野千束 2024-09-01 11:05:01 +08:00
parent 8510b0ed3f
commit ae18bfaee1
2 changed files with 0 additions and 18 deletions

View File

@ -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") # 主动通道

View File

@ -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):