Skip to content

Commit 3c0f14f

Browse files
author
gabino
committed
Refactor retrieve_uris function to use a simple for loop instead of ThreadPoolExecutor
1 parent ceb1d41 commit 3c0f14f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cuenca/resources/resources.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
from concurrent.futures import ThreadPoolExecutor
32
from typing import Dict, List, cast
43

54
from .base import Retrievable
@@ -17,5 +16,11 @@ def retrieve_uri(uri: str) -> Retrievable:
1716

1817

1918
def retrieve_uris(uris: List[str]) -> List[Retrievable]:
20-
with ThreadPoolExecutor(max_workers=len(uris)) as executor:
21-
return [obj for obj in executor.map(retrieve_uri, uris)]
19+
# Changed the implementation to use a simple for loop instead of
20+
# ThreadPoolExecutor. The list of URIs is small, so the performance
21+
# difference is negligible. Additionally, using ThreadPoolExecutor
22+
# caused issues with VCR tests, as the recordings were not retrieved
23+
# in the correct order, leading to unexpected HTTP calls instead of
24+
# using the mocked recordings.
25+
26+
return [retrieve_uri(uri) for uri in uris]

0 commit comments

Comments
 (0)