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

Function test_AsyncQueue

tests/unittest/llmapi/test_llm_utils.py:67–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66
67def test_AsyncQueue():
68 queue = AsyncQueue()
69
70 # put data to queue sync in a thread
71 # async get data from queue in the current event loop
72 # NOTE: the event loop in the two threads are different
73
74 def put_data_to_queue():
75 for i in range(10):
76 time.sleep(0.1)
77 queue.put(i)
78
79 async def get_data_from_queue():
80 for i in range(10):
81 print(f"get: {queue.get()}")
82
83 thread = threading.Thread(target=put_data_to_queue)
84 thread.start()
85 asyncio.run(get_data_from_queue())
86 thread.join()

Callers

nothing calls this directly

Calls 4

AsyncQueueClass · 0.90
get_data_from_queueFunction · 0.85
startMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected