Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This reverts commit c0f4a49.
  • Loading branch information
hanhaowen-mt committed May 13, 2024
1 parent d8df156 commit 126876b
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions python/paddle/distributed/fleet/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import re
import shutil
import subprocess
import time

# (TODO: GhostScreaming) It will be removed later.
Expand Down Expand Up @@ -514,34 +513,6 @@ def _run_cmd(self, cmd, redirect_stderr=False, retry_times=5):

return ret, output.splitlines()

def _run_safe_cmd(self, cmd, redirect_stderr=False, retry_times=5):
exe_cmd = [self._base_cmd] + cmd.split()
ret = 0
output = ""
retry_sleep_second = 3
for x in range(retry_times + 1):
try:
process = subprocess.run(
exe_cmd,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
if redirect_stderr
else subprocess.PIPE,
text=True,
)
output = process.stdout
break
except subprocess.CalledProcessError as e:
ret = e.returncode
output = e.output
time.sleep(retry_sleep_second)
except Exception as e:
break

if ret == 134:
raise FSShellCmdAborted(cmd)

@_handle_errors()
def list_dirs(self, fs_path):
"""
Expand Down Expand Up @@ -611,8 +582,8 @@ def ls_dir(self, fs_path):
return self._ls_dir(fs_path)

def _ls_dir(self, fs_path):
cmd = ["-ls", fs_path]
ret, lines = self._run_safe_cmd(cmd)
cmd = f"ls {fs_path}"
ret, lines = self._run_cmd(cmd)

if ret != 0:
raise ExecuteError(cmd)
Expand Down

0 comments on commit 126876b

Please sign in to comment.