Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pytest-xprocess for openSUSE:Factory checked in at 2023-05-09 13:06:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-xprocess (Old) and /work/SRC/openSUSE:Factory/.python-pytest-xprocess.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-xprocess" Tue May 9 13:06:25 2023 rev:4 rq:1084894 version:0.22.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-xprocess/python-pytest-xprocess.changes 2023-04-25 16:53:25.302153431 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-xprocess.new.1533/python-pytest-xprocess.changes 2023-05-09 13:06:34.700749751 +0200 @@ -1,0 +2,15 @@ +Thu May 4 22:29:31 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 0.22.2: + * Python 3.10 is now officially supported + * `surrogateescape` will now be used as error handling strategy + for encode/decode operations. + * Make log files persistency, added in `0.21.0`, optional, + defaulting to True. The previous logging behavior (prior to + `0.21.0`) can be enabled by setting `persist_logs` flag to + `False` when calling `XProcess.ensure`. + * Fix resource warnings due to leaked internal file handles + * Ignore zombie processes which are erroneously considered + alive with python 3.11 + +------------------------------------------------------------------- Old: ---- pytest-xprocess-0.21.0.tar.gz New: ---- pytest-xprocess-0.22.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-xprocess.spec ++++++ --- /var/tmp/diff_new_pack.zb1jpT/_old 2023-05-09 13:06:35.360753679 +0200 +++ /var/tmp/diff_new_pack.zb1jpT/_new 2023-05-09 13:06:35.364753703 +0200 @@ -20,7 +20,7 @@ %define skip_python2 1 %{?sle15_python_module_pythons} Name: python-pytest-xprocess -Version: 0.21.0 +Version: 0.22.2 Release: 0 Summary: A pytest plugin for managing processes across test runs License: MIT ++++++ pytest-xprocess-0.21.0.tar.gz -> pytest-xprocess-0.22.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/.github/workflows/main.yml new/pytest-xprocess-0.22.2/.github/workflows/main.yml --- old/pytest-xprocess-0.21.0/.github/workflows/main.yml 2022-08-15 11:38:43.000000000 +0200 +++ new/pytest-xprocess-0.22.2/.github/workflows/main.yml 2023-01-05 17:03:47.000000000 +0100 @@ -6,9 +6,11 @@ strategy: fail-fast: false matrix: - python: ["3.7", "3.8", "3.9"] + python: ["3.7", "3.8", "3.9", "3.10"] os: [ubuntu-latest, windows-latest, macos-latest] include: + - python: "3.10" + tox_env: "py310" - python: "3.7" tox_env: "py37" - python: "3.8" @@ -44,24 +46,24 @@ run: | tox -e linting deploy: - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - runs-on: ubuntu-latest - needs: [build, linting] - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.7" - - name: Install wheel - run: | - python -m pip install --upgrade pip setuptools - pip install wheel - - name: Build package - run: | - python setup.py sdist bdist_wheel - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_token }} + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + runs-on: ubuntu-latest + needs: [build, linting] + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.7" + - name: Install wheel + run: | + python -m pip install --upgrade pip setuptools + pip install wheel + - name: Build package + run: | + python setup.py sdist bdist_wheel + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_token }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/.pre-commit-config.yaml new/pytest-xprocess-0.22.2/.pre-commit-config.yaml --- old/pytest-xprocess-0.21.0/.pre-commit-config.yaml 2022-11-27 16:45:01.000000000 +0100 +++ new/pytest-xprocess-0.22.2/.pre-commit-config.yaml 2022-12-31 17:53:34.000000000 +0100 @@ -1,24 +1,24 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.1 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: https://github.com/asottile/reorder_python_imports - rev: v3.8.4 + rev: v3.9.0 hooks: - id: reorder-python-imports - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [flake8-bugbear] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-byte-order-marker - id: trailing-whitespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/CHANGELOG.rst new/pytest-xprocess-0.22.2/CHANGELOG.rst --- old/pytest-xprocess-0.21.0/CHANGELOG.rst 2022-11-27 18:03:35.000000000 +0100 +++ new/pytest-xprocess-0.22.2/CHANGELOG.rst 2023-01-05 17:03:54.000000000 +0100 @@ -1,3 +1,13 @@ +0.22.2 (2023-01-05) +------------------- + +- Python 3.10 is now officially supported +- `surrogateescape` will now be used as error handling strategy for encode/decode operations. (`#127 <https://github.com/pytest-dev/pytest-xprocess/pull/127>`) +- Make log files persistency, added in `0.21.0`, optional, defaulting to True. The previous logging behavior (prior to `0.21.0`) can be enabled by setting `persist_logs` flag to `False` when calling `XProcess.ensure`. (`#122 <https://github.com/pytest-dev/pytest-xprocess/pull/122>`_) +- Fix resource warnings due to leaked internal file handles (`#121 <https://github.com/pytest-dev/pytest-xprocess/pull/121>`_) +- Ignore zombie processes which are erroneously considered alive with python 3.11 + (`#117 <https://github.com/pytest-dev/pytest-xprocess/pull/118>`_) + 0.21.0 (2022-11-27) ------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/PKG-INFO new/pytest-xprocess-0.22.2/PKG-INFO --- old/pytest-xprocess-0.21.0/PKG-INFO 2022-11-27 18:20:27.195870900 +0100 +++ new/pytest-xprocess-0.22.2/PKG-INFO 2023-01-05 17:23:37.206977400 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-xprocess -Version: 0.21.0 +Version: 0.22.2 Summary: A pytest plugin for managing processes across test runs. Home-page: https://github.com/pytest-dev/pytest-xprocess/ Author: Holger Krekel @@ -14,10 +14,12 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=3.7 +Description-Content-Type: text/x-rst License-File: LICENSE pytest-xprocess diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/RELEASING.rst new/pytest-xprocess-0.22.2/RELEASING.rst --- old/pytest-xprocess-0.21.0/RELEASING.rst 2022-08-15 11:33:20.000000000 +0200 +++ new/pytest-xprocess-0.22.2/RELEASING.rst 2023-01-04 20:01:58.000000000 +0100 @@ -24,9 +24,9 @@ $ pip install tox -#. Update the necessary files with:: +#. Run the test suite and ensure everything passes:: - $ tox -e release -- X.Y.Z + $ tox #. Commit and push the branch for review. @@ -36,6 +36,4 @@ $ git tag $VERSION release-$VERSION $ git push g...@github.com:pytest-dev/pytest-xprocess.git $VERSION - That will build the package and publish it on ``PyPI`` automatically. - #. Merge ``release-X.Y.Z`` branch into master. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/pyproject.toml new/pytest-xprocess-0.22.2/pyproject.toml --- old/pytest-xprocess-0.21.0/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-xprocess-0.22.2/pyproject.toml 2023-01-05 16:26:55.000000000 +0100 @@ -0,0 +1,7 @@ +[build-system] +requires = [ + "setuptools>=45.0", + "setuptools-scm[toml]>=6.2.3", +] + +[tool.setuptools_scm] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/pytest_xprocess.egg-info/PKG-INFO new/pytest-xprocess-0.22.2/pytest_xprocess.egg-info/PKG-INFO --- old/pytest-xprocess-0.21.0/pytest_xprocess.egg-info/PKG-INFO 2022-11-27 18:20:27.000000000 +0100 +++ new/pytest-xprocess-0.22.2/pytest_xprocess.egg-info/PKG-INFO 2023-01-05 17:23:37.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pytest-xprocess -Version: 0.21.0 +Version: 0.22.2 Summary: A pytest plugin for managing processes across test runs. Home-page: https://github.com/pytest-dev/pytest-xprocess/ Author: Holger Krekel @@ -14,10 +14,12 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Requires-Python: >=3.7 +Description-Content-Type: text/x-rst License-File: LICENSE pytest-xprocess diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/pytest_xprocess.egg-info/SOURCES.txt new/pytest-xprocess-0.22.2/pytest_xprocess.egg-info/SOURCES.txt --- old/pytest-xprocess-0.21.0/pytest_xprocess.egg-info/SOURCES.txt 2022-11-27 18:20:27.000000000 +0100 +++ new/pytest-xprocess-0.22.2/pytest_xprocess.egg-info/SOURCES.txt 2023-01-05 17:23:37.000000000 +0100 @@ -7,6 +7,7 @@ MANIFEST.in README.rst RELEASING.rst +pyproject.toml setup.cfg setup.py tox.ini diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/setup.cfg new/pytest-xprocess-0.22.2/setup.cfg --- old/pytest-xprocess-0.21.0/setup.cfg 2022-11-27 18:20:27.196267400 +0100 +++ new/pytest-xprocess-0.22.2/setup.cfg 2023-01-05 17:23:37.207497600 +0100 @@ -6,6 +6,7 @@ license_files = LICENSE url = https://github.com/pytest-dev/pytest-xprocess/ long_description = file: README.rst +long_description_content_type = text/x-rst description = A pytest plugin for managing processes across test runs. classifiers = Framework :: Pytest @@ -16,14 +17,13 @@ Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 Topic :: Software Development :: Testing Topic :: Software Development :: Libraries Topic :: Utilities [options] packages = find: -setup_requires = - setuptools_scm python_requires = >= 3.7 [options.packages.find] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/setup.py new/pytest-xprocess-0.22.2/setup.py --- old/pytest-xprocess-0.21.0/setup.py 2022-11-27 18:16:43.000000000 +0100 +++ new/pytest-xprocess-0.22.2/setup.py 2023-01-03 15:26:01.000000000 +0100 @@ -3,7 +3,6 @@ if __name__ == "__main__": setup( name="pytest-xprocess", - use_scm_version=True, # this is for GitHub's dependency graph install_requires=["pytest>=2.8", "psutil", "py"], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/tests/server.py new/pytest-xprocess-0.22.2/tests/server.py --- old/pytest-xprocess-0.21.0/tests/server.py 2022-09-11 16:58:49.000000000 +0200 +++ new/pytest-xprocess-0.22.2/tests/server.py 2023-01-05 15:10:05.000000000 +0100 @@ -27,33 +27,40 @@ allow_reuse_address = True def write_test_patterns(self): - self.write_blank_lines() - self.write_complex_strings() - self.write_non_ascii() - sys.stderr.write("started\n") - self.write_long_output() + self.write_blank_lines(100) + self.write_complex_strings(10) + self.write_non_ascii(8) + sys.stderr.write("started\n") # 18 line + self.write_long_output(100) + self.write_garbage_bytes(10) sys.stderr.write("finally started\n") sys.stderr.flush() - def write_long_output(self): + def write_long_output(self, n): """write several lines to test pattern matching with process with a lot of output""" - for _ in range(50): + for _ in range(n): sys.stderr.write("spam, bacon, eggs\n") - def write_non_ascii(self): + def write_non_ascii(self, n): """non-ascii characters must be supported""" - for _ in range(5): + for _ in range(n): sys.stderr.write("Ã�æ�pP��çîöÄ�P��adÃ¥ráøū\n") - def write_complex_strings(self): + def write_garbage_bytes(self, n): + """non-mapable bytes characters must not break xprocess""" + for _ in range(n): + sys.stderr.buffer.write(b"\x90\x81\x91") + sys.stderr.write("\n") + + def write_complex_strings(self, n): """Special/control characters should not cause problems""" - for i in range(5): + for i in range(n): sys.stderr.write(f"{i} , % /.%,@%@._%%# #/%/ %\n") - def write_blank_lines(self): + def write_blank_lines(self, n): """Blank lines should be igored by xprocess""" - for _ in range(100): + for _ in range(n): sys.stderr.write("\n") def fork_children(self, target, amount): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/tests/test_process_initialization.py new/pytest-xprocess-0.22.2/tests/test_process_initialization.py --- old/pytest-xprocess-0.21.0/tests/test_process_initialization.py 2022-08-15 11:38:43.000000000 +0200 +++ new/pytest-xprocess-0.22.2/tests/test_process_initialization.py 2023-01-05 15:10:05.000000000 +0100 @@ -50,9 +50,9 @@ @pytest.mark.parametrize( "proc_name,proc_pttrn,lines", [ - ("s1", "started", 20), + ("s1", "started", 21), ("s2", "spam, bacon, eggs", 30), - ("s3", "finally started", 62), + ("s3", "finally started", 130), ], ) def test_startup_detection_max_read_lines( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/tox.ini new/pytest-xprocess-0.22.2/tox.ini --- old/pytest-xprocess-0.21.0/tox.ini 2022-08-15 11:38:43.000000000 +0200 +++ new/pytest-xprocess-0.22.2/tox.ini 2022-12-31 17:53:34.000000000 +0100 @@ -1,5 +1,5 @@ [tox] -envlist=begin,py{37,38,39} +envlist=begin,py{37,38,39,310} [testenv:dev] commands = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/xprocess/pytest_xprocess.py new/pytest-xprocess-0.22.2/xprocess/pytest_xprocess.py --- old/pytest-xprocess-0.21.0/xprocess/pytest_xprocess.py 2022-11-27 17:22:15.000000000 +0100 +++ new/pytest-xprocess-0.22.2/xprocess/pytest_xprocess.py 2023-01-05 15:10:05.000000000 +0100 @@ -56,7 +56,7 @@ request.config._xprocess = xproc # start every run with clean log files for log_file in get_log_files(xproc.rootdir): - open(log_file, "w").close() + open(log_file, errors="surrogateescape").close() yield xproc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-xprocess-0.21.0/xprocess/xprocess.py new/pytest-xprocess-0.22.2/xprocess/xprocess.py --- old/pytest-xprocess-0.21.0/xprocess/xprocess.py 2022-11-27 16:45:01.000000000 +0100 +++ new/pytest-xprocess-0.22.2/xprocess/xprocess.py 2023-01-05 15:10:05.000000000 +0100 @@ -83,11 +83,13 @@ for p in reversed(kill_list): self._signal_process(p, signal.SIGTERM) _, alive = psutil.wait_procs(kill_list, timeout=timeout) + alive = [a for a in alive if a.status() != psutil.STATUS_ZOMBIE] # forcefully terminate procs still running for p in alive: self._signal_process(p, signal.SIGKILL) _, alive = psutil.wait_procs(kill_list, timeout=timeout) + alive = [a for a in alive if a.status() != psutil.STATUS_ZOMBIE] # even if termination itself fails, # the signal has been sent to the process @@ -134,7 +136,7 @@ def __init__(self, timeout): self.timeout = timeout # handle to the process logfile - self.fhandle = None + self.fhandles = [] # XProcessInfo holding information on XProcess instance self.info = None # Each XProcess will have a related Popen instance @@ -147,13 +149,14 @@ def __repr__(self): return "<XProcessResources {}, {}, {}>".format( - self.fhandle, self.info, self.popen + self.fhandles, self.info, self.popen ) def release(self): # file handles should always be closed # in order to avoid ResourceWarnings - self.fhandle.close() + for fhandle in self.fhandles: + fhandle.close() # We should wait on procs exit status if # termination signal has been issued @@ -199,7 +202,7 @@ return XProcessInfo(self.rootdir, name) - def ensure(self, name, preparefunc, restart=False): + def ensure(self, name, preparefunc, restart=False, persist_logs=True): """Returns (PID, logfile) from a newly started or already running process. @@ -214,40 +217,38 @@ @return: (PID, logfile) logfile will be seeked to the end if the server was running, otherwise seeked to the line after where the waitpattern matched.""" - from subprocess import Popen, STDOUT xresource = XProcessResources(self.proc_wait_timeout) + self.resources.append(xresource) info = self.getinfo(name) if not restart and not info.isrunning(): restart = True if restart: - # ensure the process is terminated first if info.pid is not None: info.terminate() + # TODO: after droping py module, review this and break + # it down into more readable chunks, possibly extracting pieces + # into internal methods would make things more clear too controldir = info.controldir.ensure(dir=1) starter = preparefunc(controldir, self) args = [str(x) for x in starter.args] self.log.debug("%s$ %s", controldir, " ".join(args)) - stdout = open(str(info.logpath), "a+b", 0) - stdout.write(bytes(f"{XPROCESS_BLOCK_DELIMITER}\n", "utf8")) - - # is env still necessary? we could pass all in popen_kwargs + if persist_logs: + stdout = open(str(info.logpath), "a+b", 0) + stdout.write(bytes(f"{XPROCESS_BLOCK_DELIMITER}\n", "utf8")) + else: + stdout = open(str(info.logpath), "wb", 0) kwargs = {"env": starter.env} - popen_kwargs = { "cwd": str(controldir), "stdout": stdout, "stderr": STDOUT, - # this gives the user the ability to - # override the previous keywords if - # desired **starter.popen_kwargs, } - if sys.platform == "win32": # pragma: no cover kwargs["startupinfo"] = sinfo = std.subprocess.STARTUPINFO() sinfo.dwFlags |= std.subprocess.STARTF_USESHOWWINDOW @@ -256,8 +257,7 @@ kwargs["close_fds"] = True kwargs["preexec_fn"] = os.setpgrp # no CONTROL-C - # keep references of all popen - # and info objects for cleanup + # keep references of all popen and info objects for cleanup xresource.info = (info, starter.terminate_on_interrupt) xresource.popen = Popen(args, **popen_kwargs, **kwargs) @@ -266,28 +266,20 @@ self.log.debug("process %r started pid=%s", name, pid) stdout.close() - # keep track of all file handles so we can - # cleanup later during teardown phase - xresource.fhandle = info.logpath.open() - - # skip previous process logs - lines = info.logpath.open().readlines() - if lines: - proc_block_counter = sum( - 1 for line in lines if XPROCESS_BLOCK_DELIMITER in line - ) - for line in xresource.fhandle: - if XPROCESS_BLOCK_DELIMITER in line: - proc_block_counter -= 1 - if proc_block_counter <= 0: - break + log_file_handle = open(info.logpath, errors="surrogateescape") + xresource.fhandles.append(log_file_handle) + pytest_extlogfiles = self.config.__dict__.setdefault("_extlogfiles", {}) + pytest_extlogfiles[name] = log_file_handle - self.resources.append(xresource) + if persist_logs: + process_log_block_handle = open(info.logpath, errors="surrogateescape") + xresource.fhandles.append(process_log_block_handle) + self._skip_previous_log_blocks(process_log_block_handle, log_file_handle) if not restart: - xresource.fhandle.seek(0, 2) + log_file_handle.seek(0, 2) else: - if not starter.wait(xresource.fhandle): + if not starter.wait(log_file_handle): raise RuntimeError( "Could not start process {}, the specified " "log pattern was not found within {} lines.".format( @@ -296,12 +288,21 @@ ) self.log.debug("%s process startup detected", name) - pytest_extlogfiles = self.config.__dict__.setdefault("_extlogfiles", {}) - pytest_extlogfiles[name] = xresource.fhandle - self.getinfo(name) - return info.pid, info.logpath + def _skip_previous_log_blocks(self, log_block_handle, log_file_handle): + lines = [line for line in log_block_handle] + if not lines: # cut it short if nothing to skip + return + proc_block_counter = sum( + 1 for line in lines if XPROCESS_BLOCK_DELIMITER in line + ) + for line in log_file_handle: + if XPROCESS_BLOCK_DELIMITER in line: + proc_block_counter -= 1 + if proc_block_counter <= 0: + break + def _infos(self): return (self.getinfo(p.basename) for p in self.rootdir.listdir()) @@ -372,14 +373,12 @@ def startup_check(self): """Used to assert process responsiveness after pattern match""" - return True def wait_callback(self): """Assert that process is ready to answer queries using provided callback funtion. Will raise TimeoutError if self.callback does not return True before self.timeout seconds""" - while True: sleep(0.1) if self.startup_check(): @@ -395,7 +394,6 @@ def wait(self, log_file): """Wait until the pattern is mached and callback returns successful.""" - self._max_time = datetime.now() + timedelta(seconds=self.timeout) lines = map(self.log_line, self.filter_lines(self.get_lines(log_file))) has_match = any(std.re.search(self.pattern, line) for line in lines) @@ -404,13 +402,11 @@ def filter_lines(self, lines): """fetch first <max_read_lines>, ignoring blank lines.""" - non_empty_lines = (x for x in lines if x.strip()) return itertools.islice(non_empty_lines, self.max_read_lines) def log_line(self, line): """Write line to process log file.""" - self.process.log.debug(line) return line @@ -418,13 +414,10 @@ """Read and yield one line at a time from log_file. Will raise TimeoutError if pattern is not matched before self.timeout seconds.""" - while True: line = log_file.readline() - if not line: std.time.sleep(0.1) - if datetime.now() > self._max_time: raise TimeoutError( "The provided start pattern {} could not be matched \ @@ -432,5 +425,4 @@ self.pattern, self.timeout ) ) - yield line