當前位置: 首頁>>代碼示例>>Python>>正文


Python cached_property.cached_property方法代碼示例

本文整理匯總了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))) 
開發者ID:kayagoban,項目名稱:shadowlands,代碼行數:22,代碼來源:block_callback_mixin.py

示例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',
        ) 
開發者ID:Yelp,項目名稱:data_pipeline,代碼行數:27,代碼來源:base_consumer.py

示例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 
開發者ID:openatx,項目名稱:facebook-wda,代碼行數:10,代碼來源:usbmux.py

示例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. 
開發者ID:kerrickstaley,項目名稱:genanki,代碼行數:8,代碼來源:note.py

示例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] 
開發者ID:adamchainz,項目名稱:ec2-metadata,代碼行數:6,代碼來源:ec2_metadata.py


注:本文中的cached_property.cached_property方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。