Skip to content

In get_connection, opt for if/else over superfluous try/except block #831

Description

@d-w-moore

Here,

, we depend on a KeyError being raised from the pop operation on the idle pool, to branch into an alternative approach of forging a new connection.

If however KeyError were raised from other sources, due either to unforeseen problems with the code as-is or future developments of the Pool.get_connection method, this approach could go sideways, resulting in the new connection code being executed for potentially the wrong reasons.

if/else is more direct and less likely to fail.

See this PR to view the code changes being spoken of here.

Activity

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions