diff --git a/guillotina/db/transaction.py b/guillotina/db/transaction.py index 5874f9b1d..bf41799cd 100644 --- a/guillotina/db/transaction.py +++ b/guillotina/db/transaction.py @@ -688,3 +688,13 @@ async def __aenter__(self): async def __aexit__(self, *args): return self.__exit__() + + def __del__(self): + if self._db_conn is not None: + logger.error( + f""" + Found a leak of pg connection {self._db_conn} in txn {self}. + It's not possible to return the connection to the pool + (__del__ function is not async) + """ + )