MCPcopy
hub / github.com/ModelTC/LightLLM / AsyncQueue

Class AsyncQueue

lightllm/server/httpserver/async_queue.py:4–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3
4class AsyncQueue:
5 def __init__(self):
6 self.datas = []
7 self.event = asyncio.Event()
8 self.lock = asyncio.Lock()
9
10 async def wait_to_ready(self):
11 try:
12 await asyncio.wait_for(self.event.wait(), timeout=3)
13 except asyncio.TimeoutError:
14 pass
15
16 async def get_all_data(self):
17 async with self.lock:
18 self.event.clear()
19 ans = self.datas
20 self.datas = []
21 return ans
22
23 async def put(self, obj):
24 async with self.lock:
25 self.datas.append(obj)
26 self.event.set()
27 return
28
29 async def wait_to_get_all_data(self):
30 await self.wait_to_ready()
31 handle_list = await self.get_all_data()
32 return handle_list

Callers 2

_pd_handle_taskFunction · 0.90
handle_loopMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected