Skip to content

Race condition in connection disconnect #732

Closed
@jpulec

Description

@jpulec

It seems like there is a race condition in the code for Connection.disconnect(). I run redis as a celery broker, so I seem to be running into a situation where I get a TypeError: NoneType has no attribute _close(). It would appear that in one process disconnect() is being called and setting the self._sock to None while another process has already executed the if statement that checks if self._sock is None.

    def disconnect(self):
        "Disconnects from the Redis server"
        self._parser.on_disconnect()
        if self._sock is None:
            return
        try:
            self._sock.shutdown(socket.SHUT_RDWR)
            self._sock.close()
        except socket.error:
            pass
        self._sock = None

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