You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This lead to a bunch of dangling connections for me when running a test suite in pypy where I initialized some stuff in a fixture at the start of each test. Apparently pypy doesn't garbage collect quite as aggresively and I managed to run out of available connections in postgres.
In my opinion it would make a lot of sense to end __exit__ with self._close(), since you're not supposed to use the object after the contextmanager exits anyways.
I'd be happy to submit a PR if you agree.
The text was updated successfully, but these errors were encountered:
When using
Connection
as a contextmanager, it doesn't close the connection when the context manager exits (https://github.com/chtd/psycopg2cffi/blob/master/psycopg2cffi/_impl/connection.py#L191). It only happens when it gets garbage collected (https://github.com/chtd/psycopg2cffi/blob/master/psycopg2cffi/_impl/connection.py#L184).This lead to a bunch of dangling connections for me when running a test suite in pypy where I initialized some stuff in a fixture at the start of each test. Apparently pypy doesn't garbage collect quite as aggresively and I managed to run out of available connections in postgres.
In my opinion it would make a lot of sense to end
__exit__
withself._close()
, since you're not supposed to use the object after the contextmanager exits anyways.I'd be happy to submit a PR if you agree.
The text was updated successfully, but these errors were encountered: