Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/tools.py

    r8364209 r136f86b  
    7575                                        return proc.returncode, out.decode("utf-8") if out else None
    7676                                except subprocess.TimeoutExpired:
    77                                         proc.send_signal(signal.SIGABRT)
    78                                         proc.communicate()
    79                                         return 124, str(None)
     77                                        if settings.timeout2gdb:
     78                                                print("Process {} timeout".format(proc.pid))
     79                                                proc.communicate()
     80                                                return 124, str(None)
     81                                        else:
     82                                                proc.send_signal(signal.SIGABRT)
     83                                                proc.communicate()
     84                                                return 124, str(None)
    8085
    8186        except Exception as ex:
     
    175180
    176181def which(program):
    177     fpath, fname = os.path.split(program)
    178     if fpath:
    179         if is_exe(program):
    180             return program
    181     else:
    182         for path in os.environ["PATH"].split(os.pathsep):
    183             exe_file = os.path.join(path, program)
    184             if is_exe(exe_file):
    185                 return exe_file
    186 
    187     return None
     182        fpath, fname = os.path.split(program)
     183        if fpath:
     184                if is_exe(program):
     185                        return program
     186        else:
     187                for path in os.environ["PATH"].split(os.pathsep):
     188                        exe_file = os.path.join(path, program)
     189                        if is_exe(exe_file):
     190                                return exe_file
     191        return None
    188192
    189193@contextlib.contextmanager
     
    323327        raise argparse.ArgumentTypeError(msg)
    324328
     329# Convert a function that converts a string to one that converts comma separated string.
     330def comma_separated(elements):
     331    return lambda string: [elements(part) for part in string.split(',')]
     332
    325333def fancy_print(text):
    326334        column = which('column')
     
    365373
    366374class Timed:
    367     def __enter__(self):
    368         self.start = time.time()
    369         return self
    370 
    371     def __exit__(self, *args):
    372         self.end = time.time()
    373         self.duration = self.end - self.start
     375        def __enter__(self):
     376                self.start = time.time()
     377                return self
     378
     379        def __exit__(self, *args):
     380                self.end = time.time()
     381                self.duration = self.end - self.start
    374382
    375383def timed(src, timeout):
    376384        expire = time.time() + timeout
    377385        i = iter(src)
    378         while True:
    379                 yield i.next(max(expire - time.time(), 0))
     386        with contextlib.suppress(StopIteration):
     387                while True:
     388                        yield i.next(max(expire - time.time(), 0))
Note: See TracChangeset for help on using the changeset viewer.