当前位置: 首页>>代码示例>>Python>>正文


Python utils.compute_eta函数代码示例

本文整理汇总了Python中swift.common.utils.compute_eta函数的典型用法代码示例。如果您正苦于以下问题:Python compute_eta函数的具体用法?Python compute_eta怎么用?Python compute_eta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compute_eta函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stats_line

 def stats_line(self):
     """
     Logs various stats for the currently running replication pass.
     """
     if self.replication_count:
         elapsed = (time.time() - self.start) or 0.000001
         rate = self.replication_count / elapsed
         self.logger.info(_("%(replicated)d/%(total)d (%(percentage).2f%%)"
             " partitions replicated in %(time).2fs (%(rate).2f/sec, "
             "%(remaining)s remaining)"),
             {'replicated': self.replication_count, 'total': self.job_count,
              'percentage': self.replication_count * 100.0 / self.job_count,
              'time': time.time() - self.start, 'rate': rate,
              'remaining': '%d%s' % compute_eta(self.start,
                        self.replication_count, self.job_count)})
         if self.suffix_count:
             self.logger.info(_("%(checked)d suffixes checked - "
                 "%(hashed).2f%% hashed, %(synced).2f%% synced"),
                 {'checked': self.suffix_count,
                  'hashed': (self.suffix_hash * 100.0) / self.suffix_count,
                  'synced': (self.suffix_sync * 100.0) / self.suffix_count})
             self.partition_times.sort()
             self.logger.info(_("Partition times: max %(max).4fs, "
                 "min %(min).4fs, med %(med).4fs"),
                 {'max': self.partition_times[-1],
                  'min': self.partition_times[0],
                  'med': self.partition_times[
                             len(self.partition_times) // 2]})
     else:
         self.logger.info(_("Nothing replicated for %s seconds."),
             (time.time() - self.start))
开发者ID:bn-emailops,项目名称:swift,代码行数:31,代码来源:replicator.py

示例2: stats_line

 def stats_line(self):
     """
     Logs various stats for the currently running replication pass.
     """
     if self.replication_count:
         elapsed = (time.time() - self.start) or 0.000001
         rate = self.replication_count / elapsed
         self.logger.info(
             _(
                 "%(replicated)d/%(total)d (%(percentage).2f%%)"
                 " partitions replicated in %(time).2fs (%(rate).2f/sec, "
                 "%(remaining)s remaining)"
             ),
             {
                 "replicated": self.replication_count,
                 "total": self.job_count,
                 "percentage": self.replication_count * 100.0 / self.job_count,
                 "time": time.time() - self.start,
                 "rate": rate,
                 "remaining": "%d%s" % compute_eta(self.start, self.replication_count, self.job_count),
             },
         )
         if self.suffix_count:
             self.logger.info(
                 _("%(checked)d suffixes checked - " "%(hashed).2f%% hashed, %(synced).2f%% synced"),
                 {
                     "checked": self.suffix_count,
                     "hashed": (self.suffix_hash * 100.0) / self.suffix_count,
                     "synced": (self.suffix_sync * 100.0) / self.suffix_count,
                 },
             )
             self.partition_times.sort()
             self.logger.info(
                 _("Partition times: max %(max).4fs, " "min %(min).4fs, med %(med).4fs"),
                 {
                     "max": self.partition_times[-1],
                     "min": self.partition_times[0],
                     "med": self.partition_times[len(self.partition_times) // 2],
                 },
             )
     else:
         self.logger.info(_("Nothing replicated for %s seconds."), (time.time() - self.start))
开发者ID:eternaltyro,项目名称:swift,代码行数:42,代码来源:replicator.py

示例3: direct

 def direct(obj, part, nodes):
     found_count = 0
     for node in nodes:
         error_log = get_error_log('%(ip)s:%(port)s/%(device)s' % node)
         try:
             attempts, _junk = direct_client.retry(
                 direct_client.direct_head_object, node, part, account,
                 container, obj, error_log=error_log, retries=retries,
                 headers=headers)
             retries_done[0] += attempts - 1
             found_count += 1
         except ClientException as err:
             if err.http_status not in (404, 507):
                 error_log('Giving up on /%s/%s/%s/%s: %s' % (part, account,
                           container, obj, err))
         except (Exception, Timeout) as err:
             error_log('Giving up on /%s/%s/%s/%s: %s' % (part, account,
                       container, obj, err))
     if output_missing_partitions and \
             found_count < len(nodes):
         missing = len(nodes) - found_count
         print('\r\x1B[K', end='')
         stdout.flush()
         print('# Object partition %s missing %s cop%s' % (
             part, missing, 'y' if missing == 1 else 'ies'), file=stderr)
     object_copies_found[0] += found_count
     object_copies_missing[len(nodes) - found_count] += 1
     objects_queried[0] += 1
     if time() >= next_report[0]:
         next_report[0] = time() + 5
         eta, eta_unit = compute_eta(begun, objects_queried[0],
                                     objects_listed)
         if not json_output:
             print('\r\x1B[KQuerying objects: %d of %d, %d%s left, %d '
                   'retries' % (objects_queried[0], objects_listed,
                                round(eta), eta_unit, retries_done[0]),
                   end='')
         stdout.flush()
开发者ID:chenzhongtao,项目名称:swift,代码行数:38,代码来源:dispersion_report.py


注:本文中的swift.common.utils.compute_eta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。