How to use the pyvirtualdisplay.smartdisplay.DisplayTimeoutError function in PyVirtualDisplay

To help you get started, we’ve selected a few PyVirtualDisplay 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 ponty / PyVirtualDisplay / tests / test_smart.py View on Github external
def test_slowshot_timeout():
    disp = SmartDisplay(visible=False)
    py = Path(__file__).parent / ("slowgui.py")
    proc = EasyProcess([python, py])
    with disp:
        with proc:
            with pytest.raises(DisplayTimeoutError):
                img = disp.waitgrab(timeout=1)
github ponty / PyVirtualDisplay / pyvirtualdisplay / smartdisplay.py View on Github external
repeat_time = 0.5
        while 1:
            log.debug("sleeping %s secs" % str(sleep_time))
            time.sleep(sleep_time)
            t += sleep_time
            img = self.grab(autocrop=autocrop)
            if img:
                if not cb_imgcheck:
                    break
                if cb_imgcheck(img):
                    break
            sleep_time = repeat_time
            repeat_time += 0.5  # progressive
            if t > timeout:
                msg = "Timeout! elapsed time:%s timeout:%s " % (t, timeout)
                raise DisplayTimeoutError(msg)
                # break

            log.debug("screenshot is empty, next try..")
        assert img
        #        if not img:
        #            log.debug('screenshot is empty!')
        return img