MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / _ensure_event_loop

Method _ensure_event_loop

tensorrt_llm/executor/rpc/rpc_client.py:506–527  ·  view source on GitHub ↗

Create and start the background event loop. This is called once during initialization to create the dedicated event loop for all socket I/O operations.

(self)

Source from the content-addressed store, hash-verified

504 self._pending_futures.pop(request_id, None)
505
506 def _ensure_event_loop(self):
507 """Create and start the background event loop.
508
509 This is called once during initialization to create the dedicated
510 event loop for all socket I/O operations.
511 """
512 if self._loop is not None:
513 return # Already created
514
515 self._loop = asyncio.new_event_loop()
516
517 def run_loop():
518 asyncio.set_event_loop(self._loop)
519 self._loop.run_forever()
520
521 self._loop_thread = threading.Thread(target=run_loop,
522 daemon=True,
523 name="rpc_client_loop")
524 self._loop_thread.start()
525
526 # Wait briefly to ensure the loop is running before returning
527 time.sleep(0.2)
528
529 def _call_sync(self, method_name, *args, **kwargs):
530 """Synchronous version of RPC call."""

Callers 1

__init__Method · 0.95

Calls 2

sleepMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected