MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / get

Method get

tensorrt_llm/llmapi/utils.py:418–448  ·  view source on GitHub ↗
(self, timeout=None)

Source from the content-addressed store, hash-verified

416 raise asyncio.QueueEmpty() from None
417
418 async def get(self, timeout=None):
419 if self._tainted:
420 raise AsyncQueue.MixedSyncAsyncAPIError()
421
422 # Blocking path: timeout is None (wait indefinitely)
423 if timeout is None:
424 # Wait indefinitely until the queue is non-empty.
425 # It is necessary to check if the queue is empty after waking.
426 # Because multiple waiting coroutines may be awakened simultaneously when a new item entries empty queue.
427 # These coroutines will all pop this item from queue, and then raise IndexError.
428 while not self._q:
429 await self._event.wait()
430 # Blocking path: timeout > 0 (timed wait, retry with remaining time).
431 elif timeout > 0:
432 # Compute the deadline; if the queue is still empty after waking, continue waiting for the remaining time.
433 loop = asyncio.get_running_loop()
434 deadline = loop.time() + timeout
435 while not self._q:
436 remaining = deadline - loop.time()
437 if remaining <= 0:
438 raise asyncio.TimeoutError()
439 # This may raise asyncio.TimeoutError.
440 await asyncio.wait_for(self._event.wait(), timeout=remaining)
441 # Non-blocking path: timeout <= 0.
442 elif not self._q:
443 raise asyncio.QueueEmpty()
444
445 res = self._q.popleft()
446 if not self._q:
447 self._event.clear()
448 return res
449
450
451class _SyncQueue:

Callers 15

_call_streamingMethod · 0.95
matmul_ogsFunction · 0.45
wrapperFunction · 0.45
specializeFunction · 0.45
make_opt_flagsFunction · 0.45
matmul_launch_metadataFunction · 0.45
setup.pyFile · 0.45
fmha_harness_wrapperFunction · 0.45
run_commandFunction · 0.45

Calls 2

waitMethod · 0.80
clearMethod · 0.45

Tested by 15

wrapperFunction · 0.36
merge_junit_xmlsFunction · 0.36
xml_to_htmlFunction · 0.36
filter_failed_testsFunction · 0.36
_extract_termsFunction · 0.36
_parse_testsMethod · 0.36
tests_to_stagesMethod · 0.36
stages_to_testsMethod · 0.36
recipe_to_server_configFunction · 0.36
str_dtype_to_npFunction · 0.36
test_grpc_clientFunction · 0.36