in mozregression/fetch_build_info.py [0:0]
def find_build_info(self, date, fetch_txt_info=True, max_workers=2):
"""
Find build info for a nightly build, given a date.
Returns a :class:`NightlyBuildInfo` instance.
"""
# getting a valid build for a given date on nightly is tricky.
# there is multiple possible builds folders for one date,
# and some of them may be invalid (without binary for example)
# to save time, we will try multiple build folders at the same
# time in some threads. The first good one found is returned.
try:
build_urls = self._get_urls(date)
LOG.debug("got build_urls %s" % build_urls)
except requests.HTTPError as exc:
raise BuildInfoNotFound(str(exc))
build_info = None
valid_builds = []
while build_urls:
some = build_urls[:max_workers]
threads = [
Thread(target=self._fetch_build_info_from_url, args=(url, i, valid_builds))
for i, url in enumerate(some)
]
for thread in threads:
thread.daemon = True
thread.start()
for thread in threads:
while thread.is_alive():
thread.join(0.1)
LOG.debug("got valid_builds %s" % valid_builds)
if valid_builds:
infos = sorted(valid_builds, key=lambda b: b[0])[0][1]
if fetch_txt_info:
self._update_build_info_from_txt(infos)
build_info = NightlyBuildInfo(
self.fetch_config,
build_url=infos["build_url"],
build_date=date,
changeset=infos.get("changeset"),
repo_url=infos.get("repository"),
)
break
build_urls = build_urls[max_workers:]
if build_info is None:
raise BuildInfoNotFound("Unable to find build info for %s" % date)
return build_info