MCPcopy
hub / github.com/plotly/dash / get_prop

Method get_prop

dash/backends/ws.py:129–186  ·  view source on GitHub ↗

Request current prop value from the client. Uses queue.Queue for blocking wait in worker thread. Args: component_id: The component ID (string or stringified dict) prop_name: The property name to retrieve timeout: Timeout in seconds for waiting fo

(
        self, component_id: str, prop_name: str, timeout: float = 30.0
    )

Source from the content-addressed store, hash-verified

127 self._queue_message(msg)
128
129 async def get_prop(
130 self, component_id: str, prop_name: str, timeout: float = 30.0
131 ) -> Any:
132 """Request current prop value from the client.
133
134 Uses queue.Queue for blocking wait in worker thread.
135
136 Args:
137 component_id: The component ID (string or stringified dict)
138 prop_name: The property name to retrieve
139 timeout: Timeout in seconds for waiting for response
140
141 Returns:
142 The current value of the property from the client's state
143
144 Raises:
145 WebsocketDisconnected: If the websocket connection has been closed.
146 TimeoutError: If the response doesn't arrive within the timeout.
147 """
148 if self.is_shutdown:
149 raise WebsocketDisconnected()
150
151 pending_get_props = self._get_pending_get_props()
152 if pending_get_props is None:
153 raise WebsocketDisconnected()
154
155 request_id = str(uuid.uuid4())
156 msg = {
157 "type": "get_props_request",
158 "rendererId": self._renderer_id,
159 "requestId": request_id,
160 "payload": {"componentId": component_id, "properties": [prop_name]},
161 }
162
163 # Use standard queue.Queue for response
164 response_queue: queue.Queue = queue.Queue()
165 pending_get_props[request_id] = response_queue
166
167 # Queue the outbound request via janus sync interface
168 self._queue_message(msg)
169
170 # Wait for response (blocking is OK in worker thread)
171 try:
172 result = response_queue.get(timeout=timeout)
173 if result == DISCONNECTED:
174 raise WebsocketDisconnected()
175 if result and prop_name in result:
176 return result[prop_name]
177 return None
178 except queue.Empty as exc:
179 raise TimeoutError(
180 f"Timeout waiting for {component_id}.{prop_name}"
181 ) from exc
182 finally:
183 # Get fresh reference in case of reconnection
184 current_pending = self._get_pending_get_props()
185 if current_pending is not None:
186 current_pending.pop(request_id, None)

Callers 1

read_propFunction · 0.80

Calls 5

_queue_messageMethod · 0.95
popMethod · 0.80
getMethod · 0.45

Tested by 1

read_propFunction · 0.64