MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / consumer

Function consumer

tests/integration/test_lock_behavior.py:213–225  ·  view source on GitHub ↗

Process items from queue with lock.

(consumer_id: str)

Source from the content-addressed store, hash-verified

211 await asyncio.sleep(0.01) # Simulate arrival rate
212
213 async def consumer(consumer_id: str):
214 """Process items from queue with lock."""
215 while True:
216 try:
217 item = await asyncio.wait_for(queue.get(), timeout=0.5)
218 except asyncio.TimeoutError:
219 break
220
221 async with lock:
222 # Simulate processing
223 await asyncio.sleep(0.02)
224 processed_order.append((consumer_id, item["id"]))
225 queue.task_done()
226
227 # Start producer and two consumers concurrently
228 producer_task = asyncio.create_task(producer(5))

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected