This commit is contained in:
yumoqing 2026-03-02 20:16:47 +08:00
parent 2cc7746abc
commit 06c2299778

View File

@ -42,6 +42,8 @@ async def run_proxy():
debug('run_proxy stopped...........')
async def zmq_subcribe(special_key: str, callback=None):
content = ''
try:
config = getConfig()
subscribe_url = config.subscribe_url or 'tcp://127.0.0.1:5556'
ctx = Context()
@ -50,11 +52,8 @@ async def zmq_subcribe(special_key: str, callback=None):
# 设置过滤:只接收以 special_key 开头的消息
sock.setsockopt_string(zmq.SUBSCRIBE, special_key)
debug(f"【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
content = ''
try:
while True:
# 接收消息multipart 格式,第一部分是 key第二部分是内容
if callback:
@ -75,6 +74,8 @@ async def zmq_subcribe(special_key: str, callback=None):
except asyncio.CancelledError:
exception(f'Cancelled .......')
pass
except Exception as e:
exception(f'{e}\n{format_exc()}'
finally:
sock.close()
ctx.term()