Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 05a52cd

Browse files
authored
Fix memory leak with asyncpg, for SQLAlchemy generic functions (#273)
Use SQLAlchemy caching logic for data type's result processors, instead of handling it in this library. Fixes #272
1 parent 8cd5514 commit 05a52cd

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## Unreleased
8+
9+
### Fixed
10+
11+
* Fix memory leak with asyncpg, for SQLAlchemy generic functions (#273)
12+
713
## 0.4.1 (November 16th, 2020)
814

915
### Fixed

databases/backends/postgres.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
logger = logging.getLogger("databases")
1717

1818

19-
_result_processors = {} # type: dict
20-
21-
2219
class PostgresBackend(DatabaseBackend):
2320
def __init__(
2421
self, database_url: typing.Union[DatabaseURL, str], **options: typing.Any
@@ -120,11 +117,7 @@ def __getitem__(self, key: typing.Any) -> typing.Any:
120117
else:
121118
idx, datatype = self._column_map[key]
122119
raw = self._row[idx]
123-
try:
124-
processor = _result_processors[datatype]
125-
except KeyError:
126-
processor = datatype.result_processor(self._dialect, None)
127-
_result_processors[datatype] = processor
120+
processor = datatype._cached_result_processor(self._dialect, None)
128121

129122
if processor is not None:
130123
return processor(raw)

0 commit comments

Comments
 (0)