Skip to content

Commit 47ad402

Browse files
committed
sync: add a 5 second timeout to gemato's openpgp refresh
If it takes more than 5 seconds to download a miniscule file from https://gentoo.org/.well-known/openpgpkey/ then something has gone dreadfully wrong. Most commonly, what went wrong is that the user has broken ipv6 connectivity and requests simply hangs forever (no joke -- it doesn't implement Happy Eyeballs and closed the multiple bug reports as "please use stackoverflow to ask questions about how to use requests, we are not a support forum"). Pass a timeout so that we eventually give up and try ipv4 instead. This is a crude hack and the proper solution is to make gemato handle this better, but until gemato is fixed to use a better download library we do the best we can. Bug: psf/requests#6788 Bug: gentoo/gemato#35 Bug: https://bugs.gentoo.org/779766 Signed-off-by: Eli Schwartz <[email protected]>
1 parent 747b2d2 commit 47ad402

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/portage/sync/syncbase.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,21 +330,23 @@ def noisy_refresh_keys():
330330

331331
def _get_openpgp_env(self, openpgp_key_path=None, debug=False):
332332
if gemato is not None:
333+
timeout = 15
333334
# Override global proxy setting with one provided in emerge configuration
334335
if "http_proxy" in self.spawn_kwargs["env"]:
335336
proxy = self.spawn_kwargs["env"]["http_proxy"]
336337
elif "https_proxy" in self.spawn_kwargs["env"]:
337338
proxy = self.spawn_kwargs["env"]["https_proxy"]
338339
else:
339340
proxy = None
341+
timeout = 5
340342

341343
if openpgp_key_path:
342344
openpgp_env = gemato.openpgp.OpenPGPEnvironment(
343-
proxy=proxy, debug=debug
345+
proxy=proxy, debug=debug, timeout=timeout
344346
)
345347
else:
346348
openpgp_env = gemato.openpgp.OpenPGPSystemEnvironment(
347-
proxy=proxy, debug=debug
349+
proxy=proxy, debug=debug, timeout=timeout
348350
)
349351

350352
return openpgp_env

0 commit comments

Comments
 (0)