How to use the pyppeteer.errors.ConnectionError function in pyppeteer

To help you get started, we’ve selected a few pyppeteer 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 web-platform-tests / wpt / tools / pyppeteer / pyppeteer / connection.py View on Github external
def open(self):
        if self.is_open():
            raise ConnectionError('Connection is already open')

        self.logger.info('opening')
        self._reading_thread = threading.Thread(target=lambda: self._read_forever())
        self._reading_thread.start()
        self._open_event.wait()
        self.logger.info('opened')

        if self.prefer_experimental:
            self.send(
                'Security.setIgnoreCertificateErrors',  # API status: experimental
                {'ignore': True}
            )
        else:
            self.send('Security.enable', {})  # API status: stable
            self.send(
                'Security.setOverrideCertificateErrors',  # API status: deprecated
github web-platform-tests / wpt / tools / pyppeteer / pyppeteer / connection.py View on Github external
def close(self):
        if not self.is_open():
            raise ConnectionError('Connection is not open')

        self.logger.info('closing')

        for message_id in list(self._locks.keys()):
            self._results[message_id] = ConnectionError(
                'Command interrupted by closing connection'
            )
            self._locks.pop(message_id).release()

        for target_id in list(self._sessions.keys()):
            session = self._sessions.pop(target_id)
            session.close()

        self._sessions.clear()
        self._open_event.clear()
        self._exit_event.set()
github web-platform-tests / wpt / tools / pyppeteer / pyppeteer / connection.py View on Github external
def send(self, method, params={}):
        if not self.is_open():
            raise ConnectionError('Connection is not open')

        self._message_id += 1
        message_id = self._message_id
        lock = threading.Lock()#timeout_lock.TimeoutLock()
        self._locks[message_id] = lock
        lock.acquire()

        message = {
            'id': message_id,
            'method': method,
            'params': params
        }

        self.logger.debug('SEND %s' % (message,))
        self._websocket.send(wspy.Frame(
            wspy.OPCODE_TEXT, json.dumps(message), mask=True
github web-platform-tests / wpt / tools / pyppeteer / pyppeteer / connection.py View on Github external
def close(self):
        if not self.is_open():
            raise ConnectionError('Connection is not open')

        self.logger.info('closing')

        for message_id in list(self._locks.keys()):
            self._results[message_id] = ConnectionError(
                'Command interrupted by closing connection'
            )
            self._locks.pop(message_id).release()

        for target_id in list(self._sessions.keys()):
            session = self._sessions.pop(target_id)
            session.close()

        self._sessions.clear()
        self._open_event.clear()
        self._exit_event.set()
        self._websocket.shutdown(socket.SHUT_RDWR)
        self._websocket.close()
        if threading.current_thread() != self._reading_thread:
            self._reading_thread.join()
        self._reading_thread = None
github web-platform-tests / wpt / tools / pyppeteer / pyppeteer / session.py View on Github external
def close(self):
        for message_id in list(self._locks.keys()):
            self._results[message_id] = ConnectionError(
                'Command interrupted by closing connection'
            )
            self._locks.pop(message_id).release()