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

Method __init__

fastdeploy/inter_communicator/fmq.py:197–217  ·  view source on GitHub ↗
(self, context, name: str, role: str = "producer")

Source from the content-addressed store, hash-verified

195
196class Queue(BaseComponent):
197 def __init__(self, context, name: str, role: str = "producer"):
198 endpoint = EndpointManager.get_endpoint(name)
199 super().__init__(context, endpoint)
200
201 self.name = name
202 self.role = Role(role)
203 self.copy = endpoint.copy
204 self.socket_conf = EndpointManager.config.socket_config
205 self._msg_id = 0
206
207 full_ep = f"{endpoint.protocol}://{endpoint.address}"
208
209 self.socket = self.context.socket(zmq.PUSH if self.role == Role.PRODUCER else zmq.PULL)
210 self.socket_conf.apply(self.socket, self.role == Role.PRODUCER)
211
212 if self.role == Role.PRODUCER:
213 self.socket.connect(full_ep)
214 else:
215 self.socket.bind(full_ep)
216
217 fmq_logger.info(f"Queue {name}({role}) initialized on {full_ep}")
218
219 async def put(self, data: Any, shm_threshold: int = 1024 * 1024):
220 """

Callers 1

__init__Method · 0.45

Calls 7

get_endpointMethod · 0.80
socketMethod · 0.80
bindMethod · 0.80
RoleClass · 0.70
applyMethod · 0.45
connectMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected