本文整理匯總了Python中cached_property.cached_property方法的典型用法代碼示例。如果您正苦於以下問題:Python cached_property.cached_property方法的具體用法?Python cached_property.cached_property怎麽用?Python cached_property.cached_property使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cached_property
的用法示例。
在下文中一共展示了cached_property.cached_property方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _expire_cached_properties
# 需要導入模塊: import cached_property [as 別名]
# 或者: from cached_property import cached_property [as 別名]
def _expire_cached_properties(self):
objects = self.__class__.__dict__.values()
c_props = [x for x in objects if x.__class__ == cached_property]
if len(c_props) == 0:
return
logging.info("{} attempting to expire {} properties".format(
str(self.__class__),
str(len(c_props))
))
for prop in c_props:
try:
del self.__dict__[prop.func.__name__]
logging.info("{} expired {}".format(
str(self.__class__),
prop.func.__name__
))
except KeyError as e:
logging.info("no need to expire {}".format(str(e)))
示例2: _kafka_consumer_config
# 需要導入模塊: import cached_property [as 別名]
# 或者: from cached_property import cached_property [as 別名]
def _kafka_consumer_config(self):
""" The `KafkaConsumerConfig` for the Consumer.
Notes:
This is not a `@cached_property` since there is the possibility
that the cluster_config could change during runtime and users could
leverage this for responding to topology changes.
`auto_commit` is set to False to ensure clients can determine when
they want their topic offsets committed via commit_messages(..)
"""
return KafkaConsumerConfig(
group_id=self.client_name,
cluster=self._region_cluster_config,
auto_offset_reset=self.auto_offset_reset,
auto_commit=False,
partitioner_cooldown=self.partitioner_cooldown,
use_group_sha=self.use_group_sha,
pre_rebalance_callback=self.pre_rebalance_callback,
post_rebalance_callback=self._apply_post_rebalance_callback_to_partition,
# TODO(joshszep|DATAPIPE-2143): switch to offset_storage='kafka'
# after all consumers are migrated
offset_storage='dual',
)
示例3: __init__
# 需要導入模塊: import cached_property [as 別名]
# 或者: from cached_property import cached_property [as 別名]
def __init__(self, udid: str, _usbmux = None):
assert udid, "udid should not empty"
self._usbmux = _usbmux or Usbmux()
self._udid = udid
self._info = self.info
# DeviceID will be changed if device re-plug
# So can not use cached_property here
示例4: tags
# 需要導入模塊: import cached_property [as 別名]
# 或者: from cached_property import cached_property [as 別名]
def tags(self, val):
self._tags = _TagList()
self._tags.extend(val)
# We use cached_property instead of initializing in the constructor so that the user can set the model after calling
# __init__ and it'll still work.
示例5: clear_all
# 需要導入模塊: import cached_property [as 別名]
# 或者: from cached_property import cached_property [as 別名]
def clear_all(self):
for key in tuple(self.__dict__.keys()):
if isinstance(getattr(self.__class__, key, None), cached_property):
del self.__dict__[key]