From 310e1e814d729f68deac5f6c5f21f377c2883dac Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Tue, 14 Apr 2020 22:46:10 +0000 Subject: [PATCH] metrics: Use vpython3 instead of sys.executable Apparently, uploading metrics might happen after sys.executable has been deleted. Bug: 1068263 Change-Id: Id4ab465bb97d146b688f42fb2002e29372e65555 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2148879 Commit-Queue: Anthony Polito Reviewed-by: Anthony Polito --- metrics.py | 2 +- tests/metrics_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metrics.py b/metrics.py index 7b8d04a43f..4df1a8ed70 100644 --- a/metrics.py +++ b/metrics.py @@ -184,7 +184,7 @@ class MetricsCollector(object): # We invoke a subprocess, and use stdin.write instead of communicate(), # so that we are able to return immediately, leaving the upload running in # the background. - p = subprocess.Popen([sys.executable, UPLOAD_SCRIPT], stdin=subprocess.PIPE) + p = subprocess.Popen(['vpython3', UPLOAD_SCRIPT], stdin=subprocess.PIPE) p.stdin.write(json.dumps(self._reported_metrics).encode('utf-8')) def _collect_metrics(self, func, command_name, *args, **kwargs): diff --git a/tests/metrics_test.py b/tests/metrics_test.py index 8d28633379..0776c0aac9 100644 --- a/tests/metrics_test.py +++ b/tests/metrics_test.py @@ -138,7 +138,7 @@ class MetricsCollectorTest(unittest.TestCase): self.default_metrics.update(update_metrics or {}) # Assert we invoked the script to upload them. self.Popen.assert_called_with( - [sys.executable, metrics.UPLOAD_SCRIPT], stdin=metrics.subprocess.PIPE) + ['vpython3', metrics.UPLOAD_SCRIPT], stdin=metrics.subprocess.PIPE) # Assert we collected the right metrics. write_call = self.Popen.return_value.stdin.write.call_args collected_metrics = json.loads(write_call[0][0])