Skip to content

Narrow down except OSError blocks #4989

Open

Description

@crusaderky

In case of timeout, the distributed code currently raises a generic OSError (search for: raise OSError).
There are many lines that contain except OSError or variations thereof (search for regex: except .*OSError.

In some cases, we have checks (in production, not in the unit tests) on the string repr of the caught OSError to figure out if they are actually timeouts.

As a general design rule, it pays to be as specific as possible when raising and catching exceptions.

I don't recommend changing the timeouts to TimeoutError, because:
a. TimeoutError is not a subclass of OSError, so many current except blocks would stop working and one would need to chase them all down
b. it creates confusion with asyncio.TimeoutError.

I would suggest instead creating a new exception class ConnectionTimeoutError(OSError): pass

We should search for all except .*OSError and investigate, case by case, if it's possible to narrow it down to some of its subclasses (except (CommClosedError, ConnectionTimeoutError, RPCClosed) hopefully?)
This of course carries the risk of getting overzealous and accidentally resuscitating some old infrequent crash caused by other subclasses of OSError (unhandled failures from the socket module?).

Activity

  1. fjetter commented on Jun 29, 2021

    @fjetter
    Member

    FYI #4741

  2. changed the title [-]EnvironmentError and IOError[/-] [+]Narrow down `except OSError` blocks[/+] on Jun 30, 2021
  3. crusaderky commented on Jun 30, 2021

    @crusaderky
    CollaboratorAuthor

    Rescoped and rewrote description downstream of #4741 and #5003

  4. added a commit that references this issue on Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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