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


Python utils.monotonic_time函数代码示例

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


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

示例1: _recoverExistingVms

    def _recoverExistingVms(self):
        start_time = utils.monotonic_time()
        try:
            self.log.debug('recovery: started')

            # Starting up libvirt might take long when host under high load,
            # we prefer running this code in external thread to avoid blocking
            # API response.
            mog = min(config.getint('vars', 'max_outgoing_migrations'),
                      numa.cpu_topology().cores)
            migration.SourceThread.setMaxOutgoingMigrations(mog)

            recovery.all_vms(self)

            # recover stage 3: waiting for domains to go up
            self._waitForDomainsUp()

            recovery.clean_vm_files(self)

            self._recovery = False

            # Now if we have VMs to restore we should wait pool connection
            # and then prepare all volumes.
            # Actually, we need it just to get the resources for future
            # volumes manipulations
            self._waitForStoragePool()

            self._preparePathsForRecoveredVMs()

            self.log.info('recovery: completed in %is',
                          utils.monotonic_time() - start_time)

        except:
            self.log.exception("recovery: failed")
            raise
开发者ID:kanalun,项目名称:vdsm,代码行数:35,代码来源:clientIF.py

示例2: wait_for_removal

def wait_for_removal(path, timeout, wait=0.1):
    deadline = utils.monotonic_time() + timeout
    while True:
        if not os.path.exists(path):
            return True
        if utils.monotonic_time() > deadline:
            return False
        time.sleep(wait)
开发者ID:yingyun001,项目名称:vdsm,代码行数:8,代码来源:utilsTests.py

示例3: assertMaxDuration

 def assertMaxDuration(self, maxtime):
     start = utils.monotonic_time()
     try:
         yield
     finally:
         elapsed = utils.monotonic_time() - start
         if maxtime < elapsed:
             self.fail("Operation was too slow %.2fs > %.2fs" %
                       (elapsed, maxtime))
开发者ID:fancyKai,项目名称:vdsm,代码行数:9,代码来源:iscsiTests.py

示例4: send

 def send(self):
     disp = self._disp
     timeout = self._timeout
     duration = 0
     s = monotonic_time()
     while ((timeout is None or duration < timeout) and
            (disp.writable() or not self._connected.isSet())):
             td = timeout - duration if timeout is not None else None
             self.process(td)
             duration = monotonic_time() - s
开发者ID:kripper,项目名称:vdsm,代码行数:10,代码来源:stomp.py

示例5: _work

 def _work():
     invokations[0] += 1
     invokations[1] = monotonic_time()
     if invokations[0] == BLOCK_AT:
         # must be > (PERIOD * TIMES) ~= forever
         time.sleep(10 * PERIOD * TIMES)
     executions[0] += 1
     executions[1] = monotonic_time()
     if invokations[0] == TIMES:
         done.set()
开发者ID:sshnaidm,项目名称:vdsm,代码行数:10,代码来源:periodicTests.py

示例6: test_timeout_not_triggered

    def test_timeout_not_triggered(self):
        time_start = monotonic_time()
        with monitor.Monitor(timeout=self.TIMEOUT) as mon:
            dummy_name = dummy.create()
            dummy.remove(dummy_name)

            for event in mon:
                break

        self.assertTrue((monotonic_time() - time_start) <= self.TIMEOUT)
        self.assertTrue(mon.is_stopped())
开发者ID:Caez83,项目名称:vdsm,代码行数:11,代码来源:netlinkTests.py

示例7: _serveRequest

 def _serveRequest(self, ctx, req):
     start_time = monotonic_time()
     response = self._handle_request(req, ctx.server_address)
     error = getattr(response, "error", None)
     if error is None:
         response_log = "succeeded"
     else:
         response_log = "failed (error %s)" % (error.code,)
     self.log.info("RPC call %s %s in %.2f seconds",
                   req.method, response_log, monotonic_time() - start_time)
     if response is not None:
         ctx.requestDone(response)
开发者ID:yingyun001,项目名称:vdsm,代码行数:12,代码来源:__init__.py

示例8: recv

    def recv(self):
        timeout = self._timeout
        s = monotonic_time()
        duration = 0
        while timeout is None or duration < timeout:
            try:
                return self._inbox.popleft()
            except IndexError:
                td = timeout - duration if timeout is not None else None
                self.process(td)
                duration = monotonic_time() - s

        return None
开发者ID:kripper,项目名称:vdsm,代码行数:13,代码来源:stomp.py

示例9: nic

def nic(name, model, mac, start_sample, end_sample, interval):
    ifSpeed = [100, 1000][model in ('e1000', 'virtio')]

    ifStats = {'macAddr': mac,
               'name': name,
               'speed': str(ifSpeed),
               'state': 'unknown'}

    ifStats['rxErrors'] = str(end_sample['rx.errs'])
    ifStats['rxDropped'] = str(end_sample['rx.drop'])
    ifStats['txErrors'] = str(end_sample['tx.errs'])
    ifStats['txDropped'] = str(end_sample['tx.drop'])

    rxDelta = (
        end_sample['rx.bytes'] - start_sample['rx.bytes'])
    ifRxBytes = (100.0 *
                 (rxDelta % 2 ** 32) /
                 interval / ifSpeed / _MBPS_TO_BPS)
    txDelta = (
        end_sample['tx.bytes'] - start_sample['tx.bytes'])
    ifTxBytes = (100.0 *
                 (txDelta % 2 ** 32) /
                 interval / ifSpeed / _MBPS_TO_BPS)

    ifStats['rxRate'] = '%.1f' % ifRxBytes
    ifStats['txRate'] = '%.1f' % ifTxBytes

    ifStats['rx'] = str(end_sample['rx.bytes'])
    ifStats['tx'] = str(end_sample['tx.bytes'])
    ifStats['sampleTime'] = monotonic_time()

    return ifStats
开发者ID:kripper,项目名称:vdsm,代码行数:32,代码来源:vmstats.py

示例10: tick

 def tick(self):
     now = monotonic_time()
     result = self._result(now)
     self._counter = (self._counter + 1) % self._interval
     if result:
         self._last_time = now
     return result
开发者ID:yingyun001,项目名称:vdsm,代码行数:7,代码来源:throttledlog.py

示例11: _scan

    def _scan(self):
        with closing(select.epoll()) as epoll:
            with _monitoring_socket(self._queue, self._groups, epoll) as sock:
                with _pipetrick(epoll) as self._pipetrick:
                    self._scanning_started.set()
                    while True:
                        if self._timeout:
                            timeout = self._end_time - monotonic_time()
                            # timeout expired
                            if timeout <= 0:
                                self._scanning_stopped.set()
                                self._queue.put(_TIMEOUT_FLAG)
                                break
                        else:
                            timeout = -1

                        events = NoIntrPoll(epoll.poll, timeout=timeout)
                        # poll timeouted
                        if len(events) == 0:
                            self._scanning_stopped.set()
                            self._queue.put(_TIMEOUT_FLAG)
                            break
                        # stopped by pipetrick
                        elif (self._pipetrick[0], select.POLLIN) in events:
                            NoIntrCall(os.read, self._pipetrick[0], 1)
                            self._queue.put(_STOP_FLAG)
                            break

                        _nl_recvmsgs_default(sock)
开发者ID:Caez83,项目名称:vdsm,代码行数:29,代码来源:monitor.py

示例12: _attempt_log_stats

 def _attempt_log_stats(self):
     self._counter += 1
     if monotonic_time() > self._next_report:
         self.log.info('%s requests processed during %s seconds',
                       self._counter, self._timeout)
         self._next_report += self._timeout
         self._counter = 0
开发者ID:nickxiao,项目名称:vdsm,代码行数:7,代码来源:__init__.py

示例13: __init__

 def __init__(self, bridge, timeout, threadFactory=None):
     self._bridge = bridge
     self._workQueue = Queue()
     self._threadFactory = threadFactory
     self._timeout = timeout
     self._next_report = monotonic_time() + self._timeout
     self._counter = 0
开发者ID:nickxiao,项目名称:vdsm,代码行数:7,代码来源:__init__.py

示例14: __init__

 def __init__(self, sslctx, handshake_finished_handler, handshake_timeout=SSL_HANDSHAKE_TIMEOUT):
     self._give_up_at = monotonic_time() + handshake_timeout
     self._has_been_set_up = False
     self._is_handshaking = True
     self.want_read = True
     self.want_write = True
     self._sslctx = sslctx
     self._handshake_finished_handler = handshake_finished_handler
开发者ID:fancyKai,项目名称:vdsm,代码行数:8,代码来源:sslutils.py

示例15: _resize_map

def _resize_map(name):
    """
    Invoke multipathd to resize a device
    Must run as root

    Raises Error if multipathd failed to resize the map.
    """
    log.debug("Resizing map %r", name)
    cmd = [_MULTIPATHD.cmd, "resize", "map", name]
    start = utils.monotonic_time()
    rc, out, err = utils.execCmd(cmd, raw=True, execCmdLogger=log)
    # multipathd reports some errors using non-zero exit code and stderr (need
    # to be root), but the command may return 0, and the result is reported
    # using stdout.
    if rc != 0 or out != "ok\n":
        raise Error("Resizing map %r failed: out=%r err=%r"
                    % (name, out, err))
    elapsed = utils.monotonic_time() - start
    log.debug("Resized map %r in %.2f seconds", name, elapsed)
开发者ID:kvaps,项目名称:vdsm,代码行数:19,代码来源:multipath.py


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