bugfix
This commit is contained in:
parent
a5de7478b9
commit
8ab5f767cf
@ -44,6 +44,8 @@ async def run_proxy():
|
|||||||
async def zmq_subcribe(special_key: str, callback=None):
|
async def zmq_subcribe(special_key: str, callback=None):
|
||||||
content = ''
|
content = ''
|
||||||
try:
|
try:
|
||||||
|
if callback:
|
||||||
|
debug(f"**【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
subscribe_url = config.subscribe_url or 'tcp://127.0.0.1:5556'
|
subscribe_url = config.subscribe_url or 'tcp://127.0.0.1:5556'
|
||||||
ctx = Context()
|
ctx = Context()
|
||||||
@ -52,6 +54,7 @@ async def zmq_subcribe(special_key: str, callback=None):
|
|||||||
|
|
||||||
# 设置过滤:只接收以 special_key 开头的消息
|
# 设置过滤:只接收以 special_key 开头的消息
|
||||||
sock.setsockopt_string(zmq.SUBSCRIBE, special_key)
|
sock.setsockopt_string(zmq.SUBSCRIBE, special_key)
|
||||||
|
if calback:
|
||||||
debug(f"【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
|
debug(f"【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -63,7 +66,8 @@ async def zmq_subcribe(special_key: str, callback=None):
|
|||||||
debug(f'## RECEIVED message on {special_key}:{msg}')
|
debug(f'## RECEIVED message on {special_key}:{msg}')
|
||||||
key = msg[0].decode()
|
key = msg[0].decode()
|
||||||
content = msg[1].decode()
|
content = msg[1].decode()
|
||||||
# print(f"【服务端】匹配成功!Key: {key}, 内容: {content}")
|
if callback:
|
||||||
|
debug(f"【服务端】匹配成功!Key: {key}, 内容: {content}")
|
||||||
if callback is None:
|
if callback is None:
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
@ -79,6 +83,8 @@ async def zmq_subcribe(special_key: str, callback=None):
|
|||||||
finally:
|
finally:
|
||||||
sock.close()
|
sock.close()
|
||||||
ctx.term()
|
ctx.term()
|
||||||
|
if callback:
|
||||||
|
exception(f'意外推出 .......')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
async def zmq_publish(key, content):
|
async def zmq_publish(key, content):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user