From: Giacomo Travaglini Date: Thu, 11 Jun 2020 12:33:11 +0000 (+0100) Subject: ext: Remove dead code from helper.py X-Git-Tag: v20.1.0.0~574 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7864b174bca242aaf77eee523717a3e88cebe2e1;p=gem5.git ext: Remove dead code from helper.py This has been tested with vulture: https://pypi.org/project/vulture/ Change-Id: I32aad410145dd142bba8e0b9ab912e9c2bad6001 Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30235 Reviewed-by: Jason Lowe-Power Reviewed-by: Bobby R. Bruce Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/ext/testlib/helper.py b/ext/testlib/helper.py index 4237a765e..ff8340986 100644 --- a/ext/testlib/helper.py +++ b/ext/testlib/helper.py @@ -29,7 +29,7 @@ ''' Helper classes for writing tests with this test library. ''' -from collections import MutableSet, OrderedDict +from collections import MutableSet import difflib import errno @@ -41,9 +41,6 @@ import subprocess import tempfile import threading import time -import traceback - -from six.moves import queue as Queue #TODO Tear out duplicate logic from the sandbox IOManager def log_call(logger, command, *popenargs, **kwargs): @@ -161,7 +158,6 @@ def cacheresult(function, typed=False): .. note:: From cpython 3.7 ''' sentinel = object() # unique object used to signal cache misses - make_key = _make_key # build a key from the function arguments cache = {} def wrapper(*args, **kwds): # Simple caching without ordering or size limit @@ -350,31 +346,6 @@ def append_dictlist(dict_, key, value): list_.append(value) dict_[key] = list_ - -class ExceptionThread(threading.Thread): - ''' - Wrapper around a python :class:`Thread` which will raise an - exception on join if the child threw an unhandled exception. - ''' - def __init__(self, *args, **kwargs): - threading.Thread.__init__(self, *args, **kwargs) - self._eq = Queue.Queue() - - def run(self, *args, **kwargs): - try: - threading.Thread.run(self, *args, **kwargs) - self._eq.put(None) - except: - tb = traceback.format_exc() - self._eq.put(tb) - - def join(self, *args, **kwargs): - threading.Thread.join(*args, **kwargs) - exception = self._eq.get() - if exception: - raise Exception(exception) - - def _filter_file(fname, filters): with open(fname, "r") as file_: for line in file_: @@ -397,7 +368,6 @@ def _filter_file_inplace(fname, dir, filters): Filter the given file writing filtered lines out to a temporary file, then copy that tempfile back into the original file. ''' - reenter = False (_, tfname) = tempfile.mkstemp(dir=dir, text=True) with open(tfname, 'w') as tempfile_: for line in _filter_file(fname, filters):