Skip to content

WebSocketClient raw handling should be improved #294

@at-cf

Description

@at-cf

A client will use raw=True for performance purposes. WebSocketClient ignores this and parses messages using the inefficient json module purely for internal debugging purposes, while passing the unparsed message to the handler, which will need to be parsed again. This means that raw=True is actually slower.

It should be like this to avoid pointles parsing:

                    if not self.raw:
                        # we know cmsg is Data
                        msgJson = self.json.loads(cmsg)  # type: ignore
                        for m in msgJson:
                            if m["ev"] == "status":
                                logger.debug("status: %s", m["message"])
                                continue
                        cmsg = parse(msgJson, logger)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions