reclient_helper: delete directory synchronously
This is for
https://crrev.com/c/4916355/8/reclient_helper.py#177
Let me use synchronous directory deletion as reclient doesn't produce
many log files.
Change-Id: I44f616c9d825bc6b9dbeea329ca1db00a578a9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4988347
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Michael Savigny <msavigny@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
diff --git a/reclient_helper.py b/reclient_helper.py
index 820b070..ddeb403 100644
--- a/reclient_helper.py
+++ b/reclient_helper.py
@@ -164,25 +164,6 @@
return datetime.datetime.utcnow()
-_test_only_cleanup_logdir_handles = []
-
-
-def cleanup_logdir(log_dir):
- # Run deletetion command without waiting
- if sys.platform.startswith('win'):
- _test_only_cleanup_logdir_handles.append(
- subprocess.Popen(["rmdir", "/s/q", log_dir],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- shell=True,
- creationflags=subprocess.CREATE_NEW_PROCESS_GROUP))
- else:
- _test_only_cleanup_logdir_handles.append(
- subprocess.Popen(["rm", "-rf", log_dir],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL))
-
-
def set_reproxy_path_flags(out_dir, make_dirs=True):
"""Helper to setup the logs and cache directories for reclient.
@@ -240,7 +221,8 @@
if len(old_log_dirs) > 5:
old_log_dirs.sort(key=lambda dir: dir.split("_"), reverse=True)
for d in old_log_dirs[5:]:
- cleanup_logdir(os.path.join(log_dir, d))
+ shutil.rmtree(os.path.join(log_dir, d))
+
os.environ.setdefault("RBE_output_dir", run_log_dir)
os.environ.setdefault("RBE_proxy_log_dir", run_log_dir)
os.environ.setdefault("RBE_log_dir", run_log_dir)