MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / sub

Method sub

fastdeploy/inter_communicator/fmq.py:297–313  ·  view source on GitHub ↗
(self, callback: Callable[[Message], Any])

Source from the content-addressed store, hash-verified

295 await self._pub_socket.send(msg.serialize())
296
297 async def sub(self, callback: Callable[[Message], Any]):
298 # Subscribe and handle messages
299 if not self._sub_socket:
300 ep = f"{self.endpoint.protocol}://{self.endpoint.address}"
301 self._sub_socket = self.context.socket(zmq.SUB)
302 self._sub_socket.connect(ep)
303 self._sub_socket.setsockopt_string(zmq.SUBSCRIBE, "")
304
305 async def loop():
306 while True:
307 raw = await self._sub_socket.recv()
308 msg = Message.deserialize(raw)
309 result = callback(msg)
310 if asyncio.iscoroutine(result):
311 await result
312
313 self._task = asyncio.create_task(loop())
314
315
316# ==========================

Callers 15

get_gpu_infoFunction · 0.80
schema_formatMethod · 0.80
SubstituteTemplateFunction · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80
load_weightsMethod · 0.80

Calls 2

socketMethod · 0.80
connectMethod · 0.45

Tested by 1

run_testMethod · 0.64