bugfix
This commit is contained in:
parent
2cc7746abc
commit
06c2299778
@ -42,6 +42,8 @@ async def run_proxy():
|
|||||||
debug('run_proxy stopped...........')
|
debug('run_proxy stopped...........')
|
||||||
|
|
||||||
async def zmq_subcribe(special_key: str, callback=None):
|
async def zmq_subcribe(special_key: str, callback=None):
|
||||||
|
content = ''
|
||||||
|
try:
|
||||||
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()
|
||||||
@ -50,11 +52,8 @@ 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)
|
||||||
|
|
||||||
debug(f"【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
|
debug(f"【服务端】启动,仅等待 Key 为 '{special_key}' 的消息...")
|
||||||
|
|
||||||
content = ''
|
|
||||||
try:
|
|
||||||
while True:
|
while True:
|
||||||
# 接收消息(multipart 格式,第一部分是 key,第二部分是内容)
|
# 接收消息(multipart 格式,第一部分是 key,第二部分是内容)
|
||||||
if callback:
|
if callback:
|
||||||
@ -75,6 +74,8 @@ async def zmq_subcribe(special_key: str, callback=None):
|
|||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
exception(f'Cancelled .......')
|
exception(f'Cancelled .......')
|
||||||
pass
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
exception(f'{e}\n{format_exc()}'
|
||||||
finally:
|
finally:
|
||||||
sock.close()
|
sock.close()
|
||||||
ctx.term()
|
ctx.term()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user