From fb83e4fbc390811d02cf244c988f5e74414cb18d Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Tue, 16 Feb 2021 15:45:07 +0200 Subject: [PATCH] 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 Signed-off-by: Andrei Otcheretianski --- tests/hwsim/remotehost.py | 10 +++++----- tests/remote/rutils.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py index 9df3d8075..0799b951f 100644 --- a/tests/hwsim/remotehost.py +++ b/tests/hwsim/remotehost.py @@ -127,24 +127,24 @@ class Host(): pid_file = t.name + ".pid" - if t.isAlive(): + if t.is_alive(): cmd = ["kill `cat " + pid_file + "`"] self.execute(cmd) # try again self.thread_wait(t, 5) - if t.isAlive(): + if t.is_alive(): cmd = ["kill `cat " + pid_file + "`"] self.execute(cmd) # try with -9 self.thread_wait(t, 5) - if t.isAlive(): + if t.is_alive(): cmd = ["kill -9 `cat " + pid_file + "`"] self.execute(cmd) self.thread_wait(t, 5) - if t.isAlive(): + if t.is_alive(): raise Exception("thread still alive") self.execute(["rm", pid_file]) @@ -158,7 +158,7 @@ class Host(): wait_str = str(wait) + "s" logger.debug(self.name + " thread_wait(" + wait_str + "): ") - if t.isAlive(): + if t.is_alive(): t.join(wait) def pending(self, s, timeout=0): diff --git a/tests/remote/rutils.py b/tests/remote/rutils.py index 0585480a2..690299112 100644 --- a/tests/remote/rutils.py +++ b/tests/remote/rutils.py @@ -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): host.thread_wait(thread, timeout) - if thread.isAlive(): + if thread.is_alive(): raise Exception("ping thread still alive") 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"): client.thread_wait(client_thread, timeout) - if client_thread.isAlive(): + if client_thread.is_alive(): raise Exception("iperf client thread still alive") server.thread_wait(server_thread, 5) - if server_thread.isAlive(): + if server_thread.is_alive(): server.execute(["killall", "-s", "INT", iperf]) time.sleep(1) server.thread_wait(server_thread, 5) - if server_thread.isAlive(): + if server_thread.is_alive(): raise Exception("iperf server thread still alive") return