1
0
forked from bot/app

🐛 Ctrl+C 无法终止Channel接收线程的问题

This commit is contained in:
2024-08-16 23:43:43 +08:00
parent 0417805e46
commit 85a13251a5
6 changed files with 123 additions and 51 deletions

View File

@ -1,7 +1,7 @@
import threading
from nonebot import logger
from liteyuki.comm.channel import get_channel
from liteyuki.comm.channel import active_channel
def reload(delay: float = 0.0, receiver: str = "nonebot"):
@ -14,13 +14,9 @@ def reload(delay: float = 0.0, receiver: str = "nonebot"):
Returns:
"""
chan = get_channel(receiver + "-active")
if chan is None:
logger.error(f"Channel {receiver}-active not found, cannot reload.")
return
if delay > 0:
threading.Timer(delay, chan.send, args=(1,)).start()
threading.Timer(delay, active_channel.send, args=(1,)).start()
return
else:
chan.send(1)
active_channel.send(1)