revert semaphore gather batching (#489)
This commit is contained in:
parent
8eff15a58a
commit
ca75decc5f
2 changed files with 4 additions and 17 deletions
|
|
@ -93,21 +93,8 @@ async def semaphore_gather(
|
||||||
):
|
):
|
||||||
semaphore = asyncio.Semaphore(max_coroutines)
|
semaphore = asyncio.Semaphore(max_coroutines)
|
||||||
|
|
||||||
async def _wrap(coro: Coroutine) -> Any:
|
async def _wrap_coroutine(coroutine):
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
return await coro
|
return await coroutine
|
||||||
|
|
||||||
results = []
|
return await asyncio.gather(*(_wrap_coroutine(coroutine) for coroutine in coroutines))
|
||||||
batch = []
|
|
||||||
for coroutine in coroutines:
|
|
||||||
batch.append(_wrap(coroutine))
|
|
||||||
# once we hit max_coroutines, gather and clear the batch
|
|
||||||
if len(batch) >= max_coroutines:
|
|
||||||
results.extend(await asyncio.gather(*batch))
|
|
||||||
batch.clear()
|
|
||||||
|
|
||||||
# gather any remaining coroutines in the final batch
|
|
||||||
if batch:
|
|
||||||
results.extend(await asyncio.gather(*batch))
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[project]
|
[project]
|
||||||
name = "graphiti-core"
|
name = "graphiti-core"
|
||||||
description = "A temporal graph building library"
|
description = "A temporal graph building library"
|
||||||
version = "0.11.6pre8"
|
version = "0.11.6pre9"
|
||||||
authors = [
|
authors = [
|
||||||
{ "name" = "Paul Paliychuk", "email" = "paul@getzep.com" },
|
{ "name" = "Paul Paliychuk", "email" = "paul@getzep.com" },
|
||||||
{ "name" = "Preston Rasmussen", "email" = "preston@getzep.com" },
|
{ "name" = "Preston Rasmussen", "email" = "preston@getzep.com" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue