Skip to content

Commit 2eede7e

Browse files
committed
test: Fix FATAL: sorry, too many clients already
Within `PostgresConnector(SQLConnector)`, this aims to dispose the underlying SQLAlchemy engine object when being torn down.
1 parent a9d1796 commit 2eede7e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

target_postgres/connector.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,13 @@ def column_exists( # type: ignore[override]
799799
schema_name=schema_name, table_name=table_name, connection=connection
800800
)
801801

802+
def __del__(self):
803+
"""
804+
Dispose underlying SQLAlchemy engine object.
805+
"""
806+
if self._cached_engine is not None:
807+
self._cached_engine.dispose()
808+
802809

803810
class NOTYPE(TypeDecorator):
804811
"""Type to use when none is provided in the schema."""

0 commit comments

Comments
 (0)