支持流式容灾特性

This commit is contained in:
chenzhaoliang1228
2022-08-10 11:16:36 +08:00
committed by Your Name
parent c41f4de4ea
commit aa970803c3
34 changed files with 5765 additions and 939 deletions

View File

@ -24,6 +24,8 @@ import subprocess
import threading
import time
from subprocess import PIPE, Popen
from datetime import datetime
from datetime import timedelta
import pwd
from gspylib.common.ErrorCode import ErrorCode
from base_utils.common.exceptions import CommandNotFoundException
@ -575,6 +577,21 @@ class CmdUtil(object):
break
return status, output
@staticmethod
def retry_util_timeout(cmd, timeout, sleep_time=1):
"""
retry execute cmd with giving timeout.
"""
end_time = datetime.now() + timedelta(seconds=int(timeout))
status, output = 1, 1
while datetime.now() < end_time:
status, output = CmdUtil.getstatusoutput_by_fast_popen(cmd)
if status == 0:
break
else:
time.sleep(sleep_time)
return status, output
@staticmethod
def getstatusoutput_by_fast_popen(cmd):
"""