Skip to content

Commit

Permalink
rm semaphores
Browse files Browse the repository at this point in the history
  • Loading branch information
--global=Shreyas Pimpalgaonkar committed Oct 4, 2024
1 parent 41532f4 commit a2c407e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions py/core/providers/kg/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def __init__(

self.db_provider = db_provider.relational
self.embedding_provider = embedding_provider

self.semaphore = asyncio.Semaphore(512)


try:
import networkx as nx

Expand All @@ -66,25 +64,22 @@ async def initialize(self):
async def execute_query(
self, query: str, params: Optional[list[Any]] = None
) -> Any:
async with self.semaphore:
return await self.db_provider.execute_query(query, params)
return await self.db_provider.execute_query(query, params)

async def execute_many(
self,
query: str,
params: Optional[list[tuple[Any]]] = None,
batch_size: int = 1000,
) -> Any:
async with self.semaphore:
return await self.db_provider.execute_many(query, params, batch_size)
return await self.db_provider.execute_many(query, params, batch_size)

async def fetch_query(
self,
query: str,
params: Optional[Any] = None, # TODO: make this strongly typed
) -> Any:
async with self.semaphore:
return await self.db_provider.fetch_query(query, params)
return await self.db_provider.fetch_query(query, params)

def _get_table_name(self, base_name: str) -> str:
return self.db_provider._get_table_name(base_name)
Expand Down

0 comments on commit a2c407e

Please sign in to comment.