diff options
Diffstat (limited to 'testsuite/driver/testutil.py')
-rw-r--r-- | testsuite/driver/testutil.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py index b4159d168d..d35fb8199d 100644 --- a/testsuite/driver/testutil.py +++ b/testsuite/driver/testutil.py @@ -4,6 +4,8 @@ import platform import subprocess import shutil +import threading + def strip_quotes(s): # Don't wrap commands to subprocess.call/Popen in quotes. return s.strip('\'"') @@ -56,3 +58,25 @@ if platform.system() == 'Windows': link_or_copy_file = shutil.copyfile else: link_or_copy_file = os.symlink + +class Watcher(object): + global pool + global evt + global sync_lock + + def __init__(self, count): + self.pool = count + self.evt = threading.Event() + self.sync_lock = threading.Lock() + if count <= 0: + self.evt.set() + + def wait(self): + self.evt.wait() + + def notify(self): + self.sync_lock.acquire() + self.pool -= 1 + if self.pool <= 0: + self.evt.set() + self.sync_lock.release() |