From 3ade6e121416ba9f19925797fca934834709893c Mon Sep 17 00:00:00 2001 From: Alexander Alekseev Date: Thu, 15 Feb 2018 18:01:34 -0800 Subject: [PATCH] Override temporary directory before spawning subprocess. Python multiprocessing is using sockets to communicate. UNIX socket names are bound by PATH_MAX which includes temporary directory name. gsutil uses multiprocessing, which creates file sockets in the tmpdir. On some testing configurations, the tmpdir is set to a very long path, which causes gsutil to fail with AF_UNIX path too long errors. To prevent multiprocess failures, this CL overrides temporary directory dictated by the environment to /tmp. Bug: 812581 Change-Id: Idcd99d13b2e20b3095111fa26ec4e242848c8848 Reviewed-on: https://chromium-review.googlesource.com/923170 Reviewed-by: Ryan Tseng Commit-Queue: Alexander Alekseev --- download_from_google_storage.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index 234f8d692..4d6266a23 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -21,6 +21,11 @@ import time import subprocess2 +# Env vars that tempdir can be gotten from; minimally, this +# needs to match python's tempfile module and match normal +# unix standards. +_TEMPDIR_ENV_VARS = ('TMPDIR', 'TEMP', 'TMP') + GSUTIL_DEFAULT_PATH = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') # Maps sys.platform to what we actually want to call them. @@ -82,6 +87,9 @@ class Gsutil(object): env['AWS_CREDENTIAL_FILE'] = self.boto_path env['BOTO_CONFIG'] = self.boto_path + if PLATFORM_MAPPING[sys.platform] != 'win': + env.update((x, "/tmp") for x in _TEMPDIR_ENV_VARS) + return env def call(self, *args):