Skip to content

Commit

Permalink
cache cattrs converter to prevent memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Reskov committed May 20, 2024
1 parent 26f2682 commit ba8aa6e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion appstoreserverlibrary/models/LibraryUtility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.

from enum import EnumMeta
from functools import lru_cache
from typing import Any, List, Type, TypeVar

from attr import Attribute, has, ib, fields
Expand Down Expand Up @@ -52,7 +53,8 @@ def __attrs_post_init__(self):
elif value is not None:
setattr(self, field, value)



@lru_cache(maxsize=None)
def _get_cattrs_converter(destination_class: Type[T]) -> cattrs.Converter:
c = cattrs.Converter()
attributes: List[Attribute] = fields(destination_class)
Expand Down

0 comments on commit ba8aa6e

Please sign in to comment.