@staticmethod
def sdbCommand(command, timeout=90):
- max_retry = 20
- retry_attempt = 0
- exit_code = None
- re_stdout = None
- re_stderr = None
-
- while retry_attempt < max_retry:
- exit_code, re_stdout, re_stderr = \
- SdbManager.sdbCommand_internal(command, timeout)
- print "exit_code: %s, retry_attempt: %d, max_retry: %d" % \
- (str(exit_code), retry_attempt, max_retry)
- #print "stdout: %s, stderr: %s" % \
- # (str(re_stdout.readline()), str(re_stderr.readline()))
- if exit_code == 0:
- break
- else:
- retry_attempt += 1
- if (retry_attempt % 5) == 4:
- SdbManager.sdbCommand_internal(SDB_KILL_SERVER, timeout)
- continue
-
- if exit_code is None:
- SdbManager.killall(proc.pid)
-
- return exit_code, re_stdout, re_stderr
-
- @staticmethod
- def sdbCommand_internal(command, timeout=90):
print command
proc = subprocess.Popen(command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- time_out = 0
+ time_out = 0
exit_code = None
while time_out < timeout:
exit_code = proc.poll()
if exit_code is not None:
break
- time_out += 0.5
+ time_out += 0.5
time.sleep(0.5)
+ if exit_code is None:
+ SdbManager.killall(proc.pid)
return exit_code, proc.stdout, proc.stderr