Skip to content

Commit

Permalink
autotest: remove use of global expect_list
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Feb 18, 2021
1 parent 2d17f01 commit b7044d3
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions Tools/autotest/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
mavutil.mavlink.MAV_FRAME_GLOBAL_TERRAIN_ALT_INT
]

# a list of pexpect objects to read while waiting for
# messages. This keeps the output to stdout flowing
expect_list = []

# get location of scripts
testdir = os.path.dirname(os.path.realpath(__file__))

Expand Down Expand Up @@ -1242,6 +1238,8 @@ def __init__(self,
self.rc_thread_should_quit = False
self.rc_queue = Queue.Queue()

self.expect_list = []

def __del__(self):
if self.rc_thread is not None:
self.progress("Joining thread in __del__")
Expand Down Expand Up @@ -2183,24 +2181,20 @@ def try_symlink_tlog(self):
#################################################
def expect_list_clear(self):
"""clear the expect list."""
global expect_list
for p in expect_list[:]:
expect_list.remove(p)
for p in self.expect_list[:]:
self.expect_list.remove(p)

def expect_list_extend(self, list_to_add):
"""Extend the expect list."""
global expect_list
expect_list.extend(list_to_add)
self.expect_list.extend(list_to_add)

def expect_list_add(self, item):
"""Extend the expect list."""
global expect_list
expect_list.extend([item])
self.expect_list.extend([item])

def expect_list_remove(self, item):
"""Remove item from the expect list."""
global expect_list
expect_list.remove(item)
self.expect_list.remove(item)

def heartbeat_interval_ms(self):
c = self.context_get()
Expand Down Expand Up @@ -2244,8 +2238,7 @@ def do_heartbeats(self, force=False):
0)

def drain_all_pexpects(self):
global expect_list
for p in expect_list:
for p in self.expect_list:
util.pexpect_drain(p)

def idle_hook(self, mav):
Expand Down Expand Up @@ -2279,8 +2272,7 @@ def write_msg_to_tlog(self, msg):

def expect_callback(self, e):
"""Called when waiting for a expect pattern."""
global expect_list
for p in expect_list:
for p in self.expect_list:
if p == e:
continue
util.pexpect_drain(p)
Expand Down

0 comments on commit b7044d3

Please sign in to comment.