How to use the imjoy.imjoySocketIO_client.exceptions.TimeoutError function in imjoy

To help you get started, we’ve selected a few imjoy 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 oeway / ImJoy-Engine / imjoy / imjoySocketIO_client / heartbeats.py View on Github external
def run(self):
        try:
            while not self._halt.is_set():
                try:
                    self._send_heartbeat()
                except TimeoutError:
                    pass
                if self._adrenaline.is_set():
                    interval_in_seconds = self._hurry_interval_in_seconds
                else:
                    interval_in_seconds = self._relax_interval_in_seconds
                self._rest.wait(interval_in_seconds)
        except ConnectionError:
            logging.debug("[heartbeat connection error]")
github oeway / ImJoy-Engine / imjoy / imjoySocketIO_client / __init__.py View on Github external
def disconnect(self, path=""):
        if not path or not self._opened:
            self._close()
        elif path:
            socketIO_packet_type = 1
            socketIO_packet_data, _ = format_socketIO_packet_data(path)
            try:
                self._message(str(socketIO_packet_type) + socketIO_packet_data)
            except (TimeoutError, ConnectionError):
                pass
        try:
            namespace = self._namespace_by_path.pop(path)
            namespace.on_disconnect()
        except KeyError:
            pass
github oeway / ImJoy-Engine / imjoy / imjoySocketIO_client / transports.py View on Github external
def get_response(request, *args, **kw):
    try:
        response = request(*args, stream=True, **kw)
    except requests.exceptions.Timeout as e:
        raise TimeoutError(e)
    except requests.exceptions.ConnectionError as e:
        raise ConnectionError(e)
    except requests.exceptions.SSLError as e:
        raise ConnectionError("could not negotiate SSL (%s)" % e)
    status_code = response.status_code
    if 200 != status_code:
        raise ConnectionError(
            "unexpected status code (%s %s)" % (status_code, response.text)
        )
    return response
github oeway / ImJoy-Engine / imjoy / imjoySocketIO_client / transports.py View on Github external
def send_packet(self, engineIO_packet_type, engineIO_packet_data=""):
        packet = format_packet_text(engineIO_packet_type, engineIO_packet_data)
        try:
            self._connection.send(packet)
        except websocket.WebSocketTimeoutException as e:
            raise TimeoutError("send timed out (%s)" % e)
        except socket.error as e:
            raise ConnectionError("send disconnected (%s)" % e)
        except websocket.WebSocketConnectionClosedException as e:
            raise ConnectionError("send disconnected (%s)" % e)
github oeway / ImJoy-Engine / imjoy / imjoySocketIO_client / transports.py View on Github external
def recv_packet(self):
        try:
            packet_text = self._connection.recv()
        except websocket.WebSocketTimeoutException as e:
            raise TimeoutError("recv timed out (%s)" % e)
        except SSLError as e:
            raise ConnectionError("recv disconnected by SSL (%s)" % e)
        except websocket.WebSocketConnectionClosedException as e:
            raise ConnectionError("recv disconnected (%s)" % e)
        except socket.error as e:
            raise ConnectionError("recv disconnected (%s)" % e)
        if not isinstance(packet_text, six.binary_type):
            packet_text = six.b(packet_text)
        engineIO_packet_type, engineIO_packet_data = parse_packet_text(packet_text)
        yield engineIO_packet_type, engineIO_packet_data