Skip to content

Commit 2d57351

Browse files
Use synchronous code to download URLs. (#4376)
Use synchronous code to download URLs. This is an attempt to fix the NTP lag.
1 parent 74797c2 commit 2d57351

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/clusterfuzz/_internal/google_cloud_utils/storage.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from clusterfuzz._internal.config import local_config
3939
from clusterfuzz._internal.metrics import logs
4040
from clusterfuzz._internal.system import environment
41-
from clusterfuzz._internal.system import fast_http
4241
from clusterfuzz._internal.system import shell
4342

4443
from . import credentials
@@ -1248,6 +1247,15 @@ def get_signed_download_url(remote_path, minutes=SIGNED_URL_EXPIRATION_MINUTES):
12481247
return provider.sign_download_url(remote_path, minutes=minutes)
12491248

12501249

1250+
def _error_tolerant_download_signed_url_to_file(url_and_path):
1251+
url, path = url_and_path
1252+
try:
1253+
download_signed_url_to_file(url, path)
1254+
return url
1255+
except Exception:
1256+
return None
1257+
1258+
12511259
def _error_tolerant_upload_signed_url(url_and_path) -> bool:
12521260
url, path = url_and_path
12531261
try:
@@ -1300,7 +1308,10 @@ def download_signed_urls(signed_urls: List[str],
13001308
for idx in range(len(signed_urls))
13011309
]
13021310
logs.info('Downloading URLs.')
1303-
urls = fast_http.download_urls(signed_urls, filepaths)
1311+
with _pool() as pool:
1312+
urls = list(
1313+
pool.map(_error_tolerant_download_signed_url_to_file,
1314+
zip(signed_urls, filepaths)))
13041315
download_results = [
13051316
SignedUrlDownloadResult(url, filepaths[idx])
13061317
for idx, url in enumerate(urls)

src/clusterfuzz/_internal/system/fast_http.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from concurrent import futures
1717
import contextlib
1818
import itertools
19+
import multiprocessing
1920
from typing import List
2021
from typing import Optional
2122
from typing import Tuple
@@ -25,9 +26,7 @@
2526
from clusterfuzz._internal.metrics import logs
2627
from clusterfuzz._internal.system import environment
2728

28-
# TODO(metzman): Use cpu_count() if we can rule this out as the cause of our NTP
29-
# trouble.
30-
_POOL_SIZE = 1
29+
_POOL_SIZE = multiprocessing.cpu_count()
3130

3231

3332
@contextlib.contextmanager

0 commit comments

Comments
 (0)