Skip to content

Commit 7a53c69

Browse files
authored
improve code readability (#224)
1 parent 0a6045a commit 7a53c69

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/litserve/server.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -384,27 +384,27 @@ def api_key_auth(x_api_key: str = Depends(APIKeyHeader(name="X-API-Key"))):
384384

385385
async def response_queue_to_buffer(
386386
response_queue: mp.Queue,
387-
buffer: Dict[str, Union[Tuple[deque, asyncio.Event], asyncio.Event]],
387+
response_buffer: Dict[str, Union[Tuple[deque, asyncio.Event], asyncio.Event]],
388388
stream: bool,
389-
response_executor: ThreadPoolExecutor,
389+
threadpool: ThreadPoolExecutor,
390390
):
391391
loop = asyncio.get_running_loop()
392392
if stream:
393393
while True:
394394
try:
395-
uid, payload = await loop.run_in_executor(response_executor, response_queue.get)
395+
uid, response = await loop.run_in_executor(threadpool, response_queue.get)
396396
except Empty:
397397
await asyncio.sleep(0.0001)
398398
continue
399-
q, event = buffer[uid]
400-
q.append(payload)
399+
stream_response_buffer, event = response_buffer[uid]
400+
stream_response_buffer.append(response)
401401
event.set()
402402

403403
else:
404404
while True:
405-
uid, payload = await loop.run_in_executor(response_executor, response_queue.get)
406-
event = buffer.pop(uid)
407-
buffer[uid] = payload
405+
uid, response = await loop.run_in_executor(threadpool, response_queue.get)
406+
event = response_buffer.pop(uid)
407+
response_buffer[uid] = response
408408
event.set()
409409

410410

0 commit comments

Comments
 (0)