mirror of
				https://github.com/LiteyukiStudio/LiteyukiBot.git
				synced 2025-10-30 23:46:30 +00:00 
			
		
		
		
	🐛 fix 通道类回调函数在进程间传递时无法序列号的问题
This commit is contained in:
		| @@ -7,14 +7,19 @@ | ||||
| # @Email   : snowykami@outlook.com | ||||
| # @File    : asa.py | ||||
| # @Software: PyCharm | ||||
| import asyncio | ||||
|  | ||||
| from liteyuki.plugin import PluginMetadata | ||||
| from liteyuki import get_bot, logger | ||||
| from liteyuki.comm.channel import get_channel | ||||
|  | ||||
| __plugin_meta__ = PluginMetadata( | ||||
|     name="lifespan_monitor", | ||||
| ) | ||||
|  | ||||
| bot = get_bot() | ||||
| nbp_chan = get_channel("nonebot-passive") | ||||
| mbp_chan = get_channel("melobot-passive") | ||||
|  | ||||
|  | ||||
| @bot.on_before_start | ||||
| @@ -24,6 +29,7 @@ def _(): | ||||
|  | ||||
| @bot.on_before_shutdown | ||||
| def _(): | ||||
|     print(get_channel("main")) | ||||
|     logger.info("生命周期监控器:准备停止") | ||||
|  | ||||
|  | ||||
| @@ -35,3 +41,17 @@ def _(): | ||||
| @bot.on_after_start | ||||
| def _(): | ||||
|     logger.info("生命周期监控器:启动完成") | ||||
|  | ||||
|  | ||||
| @bot.on_after_start | ||||
| async def _(): | ||||
|     logger.info("生命周期监控器:启动完成") | ||||
|     while True: | ||||
|         await asyncio.sleep(3) | ||||
|         nbp_chan.send("send by main") | ||||
|  | ||||
|  | ||||
| @mbp_chan.on_receive() | ||||
| @nbp_chan.on_receive() | ||||
| async def _(data): | ||||
|     print("主进程收到数据", data) | ||||
|   | ||||
							
								
								
									
										10
									
								
								liteyuki/plugins/reloader_monitor.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								liteyuki/plugins/reloader_monitor.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| """ | ||||
| Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved  | ||||
|  | ||||
| @Time    : 2024/8/10 下午5:18 | ||||
| @Author  : snowykami | ||||
| @Email   : snowykami@outlook.com | ||||
| @File    : reloader_monitor.py | ||||
| @Software: PyCharm | ||||
| """ | ||||
		Reference in New Issue
	
	Block a user