|
4 | 4 | from collections.abc import Iterable
|
5 | 5 | from typing import TYPE_CHECKING, Any
|
6 | 6 |
|
| 7 | +from ..batch import InfrahubBatch |
7 | 8 | from ..exceptions import (
|
8 | 9 | Error,
|
9 | 10 | UninitializedError,
|
@@ -163,12 +164,9 @@ async def fetch(self) -> None:
|
163 | 164 | for peer in self.peers:
|
164 | 165 | if not peer.id or not peer.typename:
|
165 | 166 | raise Error("Unable to fetch the peer, id and/or typename are not defined")
|
166 |
| - if peer.typename not in ids_per_kind_map: |
167 |
| - ids_per_kind_map[peer.typename] = [peer.id] |
168 |
| - else: |
169 |
| - ids_per_kind_map[peer.typename].append(peer.id) |
| 167 | + ids_per_kind_map[peer.typename].append(peer.id) |
170 | 168 |
|
171 |
| - batch = await self.client.create_batch() |
| 169 | + batch = InfrahubBatch(max_concurrent_execution=self.client.max_concurrent_execution) |
172 | 170 | for kind, ids in ids_per_kind_map.items():
|
173 | 171 | batch.add(
|
174 | 172 | task=self.client.filters,
|
@@ -289,11 +287,9 @@ def fetch(self) -> None:
|
289 | 287 | for peer in self.peers:
|
290 | 288 | if not peer.id or not peer.typename:
|
291 | 289 | raise Error("Unable to fetch the peer, id and/or typename are not defined")
|
292 |
| - if peer.typename not in ids_per_kind_map: |
293 |
| - ids_per_kind_map[peer.typename] = [peer.id] |
294 |
| - else: |
295 |
| - ids_per_kind_map[peer.typename].append(peer.id) |
| 290 | + ids_per_kind_map[peer.typename].append(peer.id) |
296 | 291 |
|
| 292 | + # Unlike Async, no need to create a new batch from scratch because we are not using a semaphore |
297 | 293 | batch = self.client.create_batch()
|
298 | 294 | for kind, ids in ids_per_kind_map.items():
|
299 | 295 | batch.add(
|
|
0 commit comments