From c45b4b802cf9e828b8cbae2ae842f275a3ef25ba Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Thu, 6 Nov 2025 11:07:08 +0100 Subject: [PATCH 1/2] Revert "Create batch directly instead of using create_batch while fetching relationships" This reverts commit de6cfbf7f3522c5d55d01a44b4e8bf0b616552dc. --- infrahub_sdk/node/relationship.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/infrahub_sdk/node/relationship.py b/infrahub_sdk/node/relationship.py index 8473a1cb..4867efdd 100644 --- a/infrahub_sdk/node/relationship.py +++ b/infrahub_sdk/node/relationship.py @@ -4,7 +4,6 @@ from collections.abc import Iterable from typing import TYPE_CHECKING, Any -from ..batch import InfrahubBatch from ..exceptions import ( Error, UninitializedError, @@ -166,7 +165,7 @@ async def fetch(self) -> None: raise Error("Unable to fetch the peer, id and/or typename are not defined") ids_per_kind_map[peer.typename].append(peer.id) - batch = InfrahubBatch(max_concurrent_execution=self.client.max_concurrent_execution) + batch = await self.client.create_batch() for kind, ids in ids_per_kind_map.items(): batch.add( task=self.client.filters, @@ -289,7 +288,6 @@ def fetch(self) -> None: raise Error("Unable to fetch the peer, id and/or typename are not defined") ids_per_kind_map[peer.typename].append(peer.id) - # Unlike Async, no need to create a new batch from scratch because we are not using a semaphore batch = self.client.create_batch() for kind, ids in ids_per_kind_map.items(): batch.add( From 8bce2a80e5248795a6f5a072f2608f19d83c253c Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Thu, 6 Nov 2025 11:09:28 +0100 Subject: [PATCH 2/2] fix(client): do not use shared semaphore for batches It would make clients hang when using batches within batches. Signed-off-by: Fatih Acar --- infrahub_sdk/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 8e0455d7..85f363a6 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -303,7 +303,6 @@ def _initialize(self) -> None: self.object_store = ObjectStore(self) self.store = NodeStore(default_branch=self.default_branch) self.task = InfrahubTaskManager(self) - self.concurrent_execution_limit = asyncio.Semaphore(self.max_concurrent_execution) self._request_method: AsyncRequester = self.config.requester or self._default_request_method self.group_context = InfrahubGroupContext(self) @@ -1516,7 +1515,9 @@ async def allocate_next_ip_prefix( return None async def create_batch(self, return_exceptions: bool = False) -> InfrahubBatch: - return InfrahubBatch(semaphore=self.concurrent_execution_limit, return_exceptions=return_exceptions) + return InfrahubBatch( + max_concurrent_execution=self.max_concurrent_execution, return_exceptions=return_exceptions + ) async def get_list_repositories( self, branches: dict[str, BranchData] | None = None, kind: str = "CoreGenericRepository"