Skip to content

PythonParser vs HiredisParser on_disconnect behavior #1085

@popravich

Description

@popravich

PythonParser's on_disconnect implementation is inconsistent with HiredisParser implementation (or vice versa):

class PythonParser(...):
    def on_disconnect(self):
        "Called when the socket disconnects"
        if self._sock is not None:
            self._sock.close()
            self._sock = None
        if self._buffer is not None:
            self._buffer.close()
            self._buffer = None
        self.encoder = None

and

class HiredisParser(...):
    def on_disconnect(self):
        self._sock = None
        self._reader = None
        self._next_response = False

Why does the PythonParser closes the _sock object?
By doing this the subsequent shutdown() and close() in Connection.disconnect does not make any sense, in fact it shutdown on closed socket raises error which is ignored.

I can submit a PR but please tell me what place to fix? (HiredisParser/PythonParser/shutdown)

PS: this issue causes other issues in other repos (celery/kombu#954, celery/celery#3898)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions