tests: Replace deprecated thread isAlive function
The isAlive() function is deprecated in newer versions of Python so replace it with the is_alive() instead. Signed-off-by: Oren Givon <oren.givon@intel.com> Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
parent
8f248d1aca
commit
fb83e4fbc3
2 changed files with 9 additions and 9 deletions
|
@ -127,24 +127,24 @@ class Host():
|
||||||
|
|
||||||
pid_file = t.name + ".pid"
|
pid_file = t.name + ".pid"
|
||||||
|
|
||||||
if t.isAlive():
|
if t.is_alive():
|
||||||
cmd = ["kill `cat " + pid_file + "`"]
|
cmd = ["kill `cat " + pid_file + "`"]
|
||||||
self.execute(cmd)
|
self.execute(cmd)
|
||||||
|
|
||||||
# try again
|
# try again
|
||||||
self.thread_wait(t, 5)
|
self.thread_wait(t, 5)
|
||||||
if t.isAlive():
|
if t.is_alive():
|
||||||
cmd = ["kill `cat " + pid_file + "`"]
|
cmd = ["kill `cat " + pid_file + "`"]
|
||||||
self.execute(cmd)
|
self.execute(cmd)
|
||||||
|
|
||||||
# try with -9
|
# try with -9
|
||||||
self.thread_wait(t, 5)
|
self.thread_wait(t, 5)
|
||||||
if t.isAlive():
|
if t.is_alive():
|
||||||
cmd = ["kill -9 `cat " + pid_file + "`"]
|
cmd = ["kill -9 `cat " + pid_file + "`"]
|
||||||
self.execute(cmd)
|
self.execute(cmd)
|
||||||
|
|
||||||
self.thread_wait(t, 5)
|
self.thread_wait(t, 5)
|
||||||
if t.isAlive():
|
if t.is_alive():
|
||||||
raise Exception("thread still alive")
|
raise Exception("thread still alive")
|
||||||
|
|
||||||
self.execute(["rm", pid_file])
|
self.execute(["rm", pid_file])
|
||||||
|
@ -158,7 +158,7 @@ class Host():
|
||||||
wait_str = str(wait) + "s"
|
wait_str = str(wait) + "s"
|
||||||
|
|
||||||
logger.debug(self.name + " thread_wait(" + wait_str + "): ")
|
logger.debug(self.name + " thread_wait(" + wait_str + "): ")
|
||||||
if t.isAlive():
|
if t.is_alive():
|
||||||
t.join(wait)
|
t.join(wait)
|
||||||
|
|
||||||
def pending(self, s, timeout=0):
|
def pending(self, s, timeout=0):
|
||||||
|
|
|
@ -347,7 +347,7 @@ def ping_run(host, ip, result, ifname=None, addr_type="ipv4", deadline="5", qos=
|
||||||
|
|
||||||
def ping_wait(host, thread, timeout=None):
|
def ping_wait(host, thread, timeout=None):
|
||||||
host.thread_wait(thread, timeout)
|
host.thread_wait(thread, timeout)
|
||||||
if thread.isAlive():
|
if thread.is_alive():
|
||||||
raise Exception("ping thread still alive")
|
raise Exception("ping thread still alive")
|
||||||
|
|
||||||
def flush_arp_cache(host):
|
def flush_arp_cache(host):
|
||||||
|
@ -504,16 +504,16 @@ def iperf_run(server, client, server_ip, client_res, server_res,
|
||||||
|
|
||||||
def iperf_wait(server, client, server_thread, client_thread, timeout=None, iperf="iperf"):
|
def iperf_wait(server, client, server_thread, client_thread, timeout=None, iperf="iperf"):
|
||||||
client.thread_wait(client_thread, timeout)
|
client.thread_wait(client_thread, timeout)
|
||||||
if client_thread.isAlive():
|
if client_thread.is_alive():
|
||||||
raise Exception("iperf client thread still alive")
|
raise Exception("iperf client thread still alive")
|
||||||
|
|
||||||
server.thread_wait(server_thread, 5)
|
server.thread_wait(server_thread, 5)
|
||||||
if server_thread.isAlive():
|
if server_thread.is_alive():
|
||||||
server.execute(["killall", "-s", "INT", iperf])
|
server.execute(["killall", "-s", "INT", iperf])
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
server.thread_wait(server_thread, 5)
|
server.thread_wait(server_thread, 5)
|
||||||
if server_thread.isAlive():
|
if server_thread.is_alive():
|
||||||
raise Exception("iperf server thread still alive")
|
raise Exception("iperf server thread still alive")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue