Skip to content

Socket.close() is not idempotent #190

@bablokb

Description

@bablokb

The method Socket.close() has a decorator that checks if the socket is closed already. If so, the decorator throws a runtime error.

Other implementations just ignore a close() on an already closed socket which I think is the desired behavior. See also this discussion: micropython/micropython#3208

Ignoring close() is simple, since the socket keeps this state internally (self._socket_closed = True). The decorator actually checks this variable.

I can provide a PR if you agree that close() on a closed socket should just be ignored.

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