Skip to content

Feature request (to avoid bugs) - Idempotent .close() method #1042

@zenflow

Description

@zenflow

Is your feature request related to a problem? Please describe.

When you try to close a connection that is already closed, you get an exception which crashes the application if unhandled.
Django does this in some situations.

Describe the solution you'd like

Replace the raise ... statement here with a return None.

In my opinion no exception is needed here since,
although it technically could not close the connection which doesn't currently exist,
it is still guaranteed after the call that the connection is closed,
which is what the programmer really cares about.

This is (for example) the behavior of Python's base_io.close() and other Python db interfaces.

Describe alternatives you've considered

For the last 4 years we have maintained a fork that does this ourselves,
but it would be great to have it included in this upstream project,
since it will be a burden when upgrading this package.

Additional context

See where the same issue with Django + postgresql interface is discussed.
https://code.djangoproject.com/ticket/15802
I'm not sure if that was fixed or not

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