How to use the ffpuppet.helpers.wait_on_files function in ffpuppet

To help you get started, we’ve selected a few ffpuppet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MozillaSecurity / ffpuppet / ffpuppet / test_helpers.py View on Github external
def test_helpers_07(tmp_path):
    """test wait_on_files()"""
    t_file = (tmp_path / "file.bin")
    t_file.touch()
    with tempfile.NamedTemporaryFile() as wait_fp:
        assert not wait_on_files((wait_fp.name, str(t_file)), timeout=0.1)
    # existing but closed file
    assert wait_on_files([str(t_file)], timeout=0.1)
    # file that does not exist
    assert wait_on_files(["no_file"], timeout=0.1)
    # empty file list
    assert wait_on_files([])
github MozillaSecurity / ffpuppet / ffpuppet / test_helpers.py View on Github external
def test_helpers_07(tmp_path):
    """test wait_on_files()"""
    t_file = (tmp_path / "file.bin")
    t_file.touch()
    with tempfile.NamedTemporaryFile() as wait_fp:
        assert not wait_on_files((wait_fp.name, str(t_file)), timeout=0.1)
    # existing but closed file
    assert wait_on_files([str(t_file)], timeout=0.1)
    # file that does not exist
    assert wait_on_files(["no_file"], timeout=0.1)
    # empty file list
    assert wait_on_files([])
github MozillaSecurity / ffpuppet / ffpuppet / puppet_logger.py View on Github external
an error is hit before retrying.

        @rtype: None
        @return: None
        """
        if not self.closed:
            self.close()
        if self.working_path is not None and os.path.isdir(self.working_path):
            for attempt in range(2):
                try:
                    shutil.rmtree(self.working_path, ignore_errors=ignore_errors, onerror=onerror)
                    break
                except OSError:
                    if attempt > 0:
                        raise
                    wait_on_files(self.files, timeout=wait_delay)
        self._logs.clear()
        self.working_path = None
github MozillaSecurity / ffpuppet / ffpuppet / core.py View on Github external
if self._proc is not None:
            log.debug("browser pid: %r", self._proc.pid)
            crash_reports = set(self._crashreports())
            # set reason code
            if crash_reports:
                r_code = self.RC_ALERT
            elif self.is_running():
                r_code = self.RC_CLOSED
            else:
                r_code = self.RC_EXITED

            while crash_reports:
                log.debug("%d crash report(s) are available", len(crash_reports))
                # wait until all open files are closed (except stdout & stderr)
                report_wait = 300 if self._use_rr else 90
                if not wait_on_files(crash_reports, timeout=report_wait):
                    log.warning("wait_on_files(timeout=%d) Timed out", report_wait)
                    break
                new_reports = set(self._crashreports())
                # verify no new reports have appeared
                if not new_reports - crash_reports:
                    break
                log.debug("more reports have appeared")
                crash_reports = new_reports

            if self.is_running():
                log.debug("browser needs to be terminated")
                self._terminate(self._proc.pid)
                # wait for reports triggered by the call to _terminate()
                wait_on_files(self._crashreports(), timeout=10)

            # check the process exit code if needed
github MozillaSecurity / ffpuppet / ffpuppet / core.py View on Github external
report_wait = 300 if self._use_rr else 90
                if not wait_on_files(crash_reports, timeout=report_wait):
                    log.warning("wait_on_files(timeout=%d) Timed out", report_wait)
                    break
                new_reports = set(self._crashreports())
                # verify no new reports have appeared
                if not new_reports - crash_reports:
                    break
                log.debug("more reports have appeared")
                crash_reports = new_reports

            if self.is_running():
                log.debug("browser needs to be terminated")
                self._terminate(self._proc.pid)
                # wait for reports triggered by the call to _terminate()
                wait_on_files(self._crashreports(), timeout=10)

            # check the process exit code if needed
            if r_code == self.RC_EXITED and self._proc.poll() not in (0, -1, 1):
                log.debug("poll() returned %r", self._proc.poll())
                r_code = self.RC_ALERT
        else:
            r_code = self.RC_CLOSED
            log.debug("browser process was 'None'")

        if not force_close:
            if self._logs.closed:  # pragma: no cover
                # This should not happen while everything is working as expected.
                # This is here to prevent additional unexpected issues.
                # Since this should never happen in normal operation this assert
                # will help verify that.
                # If '_proc' is not None this is the first call to close()