use default value for return exceptions (#246)

This commit is contained in:
Preston Rasmussen 2024-12-17 15:11:22 -05:00 committed by GitHub
parent 7f94b0c648
commit fcff4ca67c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,16 +86,11 @@ def normalize_l2(embedding: list[float]) -> list[float]:
# Use this instead of asyncio.gather() to bound coroutines
async def semaphore_gather(
*coroutines: Coroutine, max_coroutines: int = SEMAPHORE_LIMIT, return_exceptions=True
):
async def semaphore_gather(*coroutines: Coroutine, max_coroutines: int = SEMAPHORE_LIMIT):
semaphore = asyncio.Semaphore(max_coroutines)
async def _wrap_coroutine(coroutine):
async with semaphore:
return await coroutine
return await asyncio.gather(
*(_wrap_coroutine(coroutine) for coroutine in coroutines),
return_exceptions=return_exceptions,
)
return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))