Skip to content

Commit

Permalink
Added timeout to wait_while_busy. Before it waited for finish forever.
Browse files Browse the repository at this point in the history
  • Loading branch information
voodam committed Jul 20, 2023
1 parent 43d1813 commit 9db139a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions framework/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import multiprocessing
import os

from helpers import remote, stateful, tf_cfg
from helpers import remote, stateful, tf_cfg, util


def _run_client(client, resq: multiprocessing.Queue):
Expand Down Expand Up @@ -163,6 +163,5 @@ def add_option_file(self, option, filename, content):
def set_user_agent(self, ua):
self.options.append("-H 'User-Agent: %s'" % ua)

def wait_for_finish(self):
while self.is_busy(verbose=False):
pass
def wait_for_finish(self, timeout=5):
return util.wait_until(lambda: self.is_busy(verbose=False), timeout)
7 changes: 5 additions & 2 deletions framework/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,19 @@ def tearDown(self):
self.oops_ignore = []
self.__stop_tcpdump()

def wait_while_busy(self, *items):
def wait_while_busy(self, *items, timeout=20):
if items is None:
return

success = True
for item in items:
if item.is_running():
tf_cfg.dbg(4, f'\tClient "{item}" wait for finish ')
item.wait_for_finish()
success = success and item.wait_for_finish(timeout)
tf_cfg.dbg(4, f'\tWaiting for client "{item}" is completed')

self.assertTrue(success, f"Some of items exceeded the timeout {timeout}s while finishing")

# Should replace all duplicated instances of wait_all_connections
def wait_all_connections(self, tmt=1):
for sid in self.__servers:
Expand Down

0 comments on commit 9db139a

Please sign in to comment.