-
Notifications
You must be signed in to change notification settings - Fork 203
Description
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.
edit: inserted following code reference
Lines 930 to 933 in 100df91
| if self.conn_handler is None: | |
| LogMsg(ERROR, "Connection cannot be closed; connection is no longer active.") | |
| raise ProgrammingError("Connection cannot be closed; " | |
| "connection is no longer active.") |
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