MCPcopy Index your code
hub / github.com/NVIDIA/TensorRT-LLM / safe_set_result

Method safe_set_result

tensorrt_llm/executor/rpc/rpc_client.py:257–271  ·  view source on GitHub ↗

Safely set result on future, handling race conditions.

()

Source from the content-addressed store, hash-verified

255 if not future.done():
256
257 def safe_set_result():
258 """Safely set result on future, handling race conditions."""
259 try:
260 if not future.done():
261 if response.error is None:
262 future.set_result(response.result)
263 else:
264 future.set_exception(response.error)
265 except asyncio.InvalidStateError:
266 # Future was cancelled or completed between the check and set
267 # This is expected in high-load scenarios, just log and continue
268 if enable_llmapi_debug() or logger.level == 'debug':
269 logger_debug(
270 f"[client] Future already done for request_id: {response.request_id}, skipping"
271 )
272
273 if enable_llmapi_debug() or logger.level == 'debug':
274 if response.error is None:

Callers

nothing calls this directly

Calls 2

enable_llmapi_debugFunction · 0.85
logger_debugFunction · 0.85

Tested by

no test coverage detected