Skip to content

Commit

Permalink
fixup! Issue #28 initial implementation of parallel requests (on `/jo…
Browse files Browse the repository at this point in the history
…bs`)
  • Loading branch information
soxofaan committed Oct 5, 2023
1 parent 6ae502a commit 1584d4c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/openeo_aggregator/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,6 @@ def get_connections(self) -> List[BackendConnection]:

return self._connections_cache.connections

def __len__(self) -> int:
return len(self._backend_urls)

def __iter__(self) -> Iterator[BackendConnection]:
return iter(self.get_connections())

Expand Down Expand Up @@ -386,15 +383,16 @@ def do_request(
else:
return resp.content

max_workers = min(max_workers, len(self))
connections: List[BackendConnection] = self.get_connections()
max_workers = min(max_workers, len(connections))

with TimingLogger(
title=f"request_parallel {method} {path} on {len(self)} backends with thread pool {max_workers=}",
title=f"request_parallel {method} {path} on {len(connections)} backends with thread pool {max_workers=}",
logger=_log,
), concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
# Submit all futures (one for each backend connection)
futures: List[Tuple[BackendId, concurrent.futures.Future]] = []
for con in self.get_connections():
for con in connections:
if authenticated_from_request:
auth = BearerAuth(bearer=con.extract_bearer(request=authenticated_from_request))
else:
Expand Down

0 comments on commit 1584d4c

Please sign in to comment.