# Monitoring Release
- @lazy_property
+ @functools.cached_property
async def monitoring_release(self):
"""
Returns the Monitoring Release
return False
- @lazy_property
+ @functools.cached_property
async def deprecated_by(self):
if self.data.deprecated_by:
return await self.backend.users.get_by_id(self.data.deprecated_by)
"Build", foreign_keys=[deprecating_build_id],
)
- @lazy_property
+ @functools.cached_property
async def deprecated_builds(self):
"""
Returns a list of builds that were deprecated by this build
return await asyncio.to_thread(func, *args, **kwargs)
return wrapper
-
-class lazy_property(property):
- """
- The property is only computed once and then being
- cached until the end of the lifetime of the object.
- """
- def __init__(self, fget, fset=None, fdel=None, doc=None):
- property.__init__(self, fget=fget, fset=fset, fdel=fdel, doc=doc)
-
- # Make a cache key
- self._name = "_cache_%s" % self.fget.__name__
-
- def __get__(self, instance, owner):
- if instance is None:
- return self
-
- if hasattr(instance, self._name):
- result = getattr(instance, self._name)
- else:
- if not self.fget is None:
- result = self.fget(instance)
-
- setattr(instance, self._name, result)
-
- return result
-
- def __set__(self, instance, value):
- if instance is None:
- raise AttributeError
-
- if self.fset is None:
- setattr(instance, self._name, value)
- else:
- self.fset(instance, value)
-
- # Remove any cached attributes
- try:
- delattr(instance, self._name)
- except AttributeError:
- pass