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


Python uptime.secs函数代码示例

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


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

示例1: _tick

 def _tick(self):
     reschedule = []
     entries = self._entries.popentries(uptime.secs())
     self._condition.release()
     try:
         for entry in entries:
             try:
                 entry.execute()
             except EActionExpired:
                 pass
             except EActionPremature:
                 message = 'entry %s execution premature, will reschedule'
                 self.debugout(message, STANDARDDEBUG, entry)
                 reschedule.append(entry)
             except:
                 msglog.exception()
             else: 
                 if isinstance(entry, RecurringEntry):
                     reschedule.append(entry)
     finally:
         self._condition.acquire()
     for entry in reschedule:
         entry.computewhen()
     self._entries.addentries(reschedule)
     nextrun = self._entries.nextruntime()
     if nextrun is not None:
         nextrun = max(0, nextrun - uptime.secs())
     return nextrun
开发者ID:mcruse,项目名称:monotone,代码行数:28,代码来源:_scheduler.py

示例2: _test_a

 def _test_a(self):
     point_1 = _uptime.secs()
     time.sleep(1)
     point_2 = _uptime.secs()
     diff = point_2 - point_1
     assert abs(1 - diff) < .01, "Difference should be very close to 1, was %f" % diff
     assert diff > 0, "Difference should be positive"
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:_test_case_uptime.py

示例3: get

 def get(self, skipCache=0):
     rslt = self._value
     # cache miss
     if (uptime.secs() - self._last_update) > self.group.ttl:
         # motes periodically push updates - if it's been silent for 
         # too long force an update.  @fixme: the first read will still
         # return stale data - add blocking call and ETimeout logic
         last = self._last_update
         self.__cv.acquire()
         try:
             try:
                 self._force_update()
             except:
                 # an error using the XCommand interface occured
                 # raise an exception but do not cache the ETimeout
                 msglog.exception()
                 raise ETimeout()
             self.__cv.wait(self.timeout)
             if last != self._last_update:
                 # an update has occurred
                 rslt = self._value
             else:
                 self._last_update = uptime.secs()
                 # let ETimeouts affect our value caching as well,
                 # if a better update comes from the mesh, great.
                 rslt = self._value = ETimeout()
         finally:
             self.__cv.release()
     if isinstance(rslt, ETimeout):
         raise rslt
     return rslt
开发者ID:mcruse,项目名称:monotone,代码行数:31,代码来源:lightlogic.py

示例4: wait_for_response

 def wait_for_response(self):
     then = uptime.secs()
     answer = self.poll_for_incomming_packets()
     while answer is None:
         if uptime.secs() > (then + self.timeout):
             break
         answer = self.poll_for_incomming_packets()
     return answer
开发者ID:mcruse,项目名称:monotone,代码行数:8,代码来源:cpc.py

示例5: _wait_for_skew_detection

 def _wait_for_skew_detection(self, scheduler, timerep, timeout):
     if debug:
         print '%f: Entering _wait_for_skew_detection' % uptime.secs()
     scheduler.set_checktime_callback(timerep.notify_detected)
     timerep.await_detection(timeout)
     scheduler.set_checktime_callback(None)
     if debug:
         print '%f: Returning from _wait_for_skew_detection' % uptime.secs()
开发者ID:mcruse,项目名称:monotone,代码行数:8,代码来源:_test_case_scheduler.py

示例6: _waitupto

 def _waitupto(self, timeout, waitlock):
     startuptime = uptime.secs()
     while not timeout < 0:
         msecs = min(timeout * 1000, self.MSECSMAX)
         readable = self._pollreadable(msecs)
         if waitlock.locked():
             curuptime = uptime.secs()
             lapsetime = curuptime - startuptime
             timeout = timeout - lapsetime
         else:
             break
     else:
         return False
     return True
开发者ID:mcruse,项目名称:monotone,代码行数:14,代码来源:pipebased.py

示例7: goto

 def goto(self, key_path): #send keys to destination pages & absorb all values
     path = self.key_path
     path = path.lower()
     keys = path.split(' ') #turn string into list of keywords - pun intended - that will be sent to device
     self.set_active_screen(self) #allow changes to this screen
     self.screen = None #after final key, clear the screen object to get a fresh decode
     eos = 1 #default to wait to make sure no more data
     for k in keys:
         eos = self._send_key(k)
     #self.screen = None #after final key, clear the screen object to get a fresh list of texts decoded
     if self.debug > 1: print 'start looking for values from screen'
     #now wait for string that indicated we have read in the page.
     points = filter(lambda c: isinstance(c, Point), self.children_nodes())
     point_count = len(points)
     then = uptime.secs()
     if self.debug > 1: print 'remaining points: ', [p.name for p in points]
     while points: #keep polling until all points have been seen at least once
         #filter out points that have received values since clearning screen
         points = filter(lambda p: p._get(self.screen) is None, points)
         if self.debug > 1 and len(points): print 'remaining points: ', [p.name for p in points]
         if uptime.secs() > (then + self.timeout):
             if self.debug: 
                 print CSI_RED+'Timedout waiting for screen values'+CSI_Reset   
                 if len(points): print 'remaining points: ', [p.name for p in points]
             break #timeout has occured
         self.poll_for_incomming_packets()
     self.points_screen = self.screen #make new values available to point nodes
     if eos: #true if "screen complete" was received so _send_key did not wait around for new elements to stop showing up
         eop = 0
         for i in range(20): #read in rest of screen for getting points list
             old_count = len(self.screen.texts)
             self.poll_for_incomming_packets()
             if self.screen_complete: break #this flag is reset when a zero length update is recevied
             if old_count == len(self.screen.texts):
                 if eop: break #no new points displayed for 2nd time, we are done.
                 eop = 1
         else:
             if self.debug: print CSI_RED+'Screen did not complete for value page'+CSI_Reset            
     self.last_screen = self.screen #if any new values came since nodes were satisfied, make available for texts() command
     self.set_active_screen(None) #block any further changes to this screen
     if self.debug:
         if points:
             print CSI_RED+'CPC timeout on screen', self.as_node_url(),
             for p in points:
                 print p.name,
             print ' were all not read'+CSI_Reset
         else:
             print CSI_GREEN+'CPC completed '+str(point_count)+' points for screen:', self.as_node_url(), CSI_Reset
开发者ID:mcruse,项目名称:monotone,代码行数:48,代码来源:cpc.py

示例8: get_synchronous

 def get_synchronous(self, station, rqst):
     self._sync_get_lock.acquire()
     try:
         t = self._synchronous_transaction
         hdr = self._get_auth_header(station)
         hdr['Connection'] = 'close'
         t.build_request(rqst.url, None, hdr)
         self._cv.acquire()
         try:
             response = ETimeout()
             try:
                 t.send_request()
                 self._cv.wait(self.timeout)
                 self._last_sync_get = uptime.secs()
                 if t.is_expired():
                     t.cancel()
                 else:
                     response = t.get_response()
             except:
                 t.cancel()
         finally:
             self._cv.release()
         return response
     finally:
         self._sync_get_lock.release()
     return
开发者ID:mcruse,项目名称:monotone,代码行数:26,代码来源:http_client.py

示例9: update_cache

 def update_cache(self, value_obj):
     for name, func in self._subscribers.items():
         value = value_obj.get(name)
         func(value)
     self._last_value = value
     self._last_rcvd = uptime.secs()
     return
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:http_client.py

示例10: debug_output

 def debug_output(self, message=None, location=None):
     """
         Use preferred 'debugout' method instead.
     """
     if self._debug:
         if message:
             print '%f: SCHEDULER: %s' % (uptime.secs(), message)
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:_scheduler.py

示例11: callback

 def callback(self, *args):
     #print len(args)
     if len(args) == 2:
         #append something to the passed in args
         args[1].append(args[0])
     if debug:
         print '%f: In callback with %s.' % (uptime.secs(), str(args))
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:_test_case_scheduler.py

示例12: get_next

 def get_next(self):
     try:
         transaction = self._transaction_q.get(False)
         self._backed_up = False
     except Empty:
         if self._backed_up:
             self.recycle_expired_transactions()
             transaction = self._transaction_q.get(False)
         else:
             self._backed_up = True
             raise
     now = uptime.secs()
     fresh = []
     while 1:
         try:
             rqst = self._request_q.get(False)
             if (now - rqst.last_update) > rqst.ttl:
                 break
             fresh.append(rqst)
         except Empty:
             rqst = None
             break
     map(self._request_q.put, fresh)
     if rqst is None:    
         self.put_transaction(transaction)
         raise Empty                    
     return (transaction, rqst)
开发者ID:mcruse,项目名称:monotone,代码行数:27,代码来源:http_client.py

示例13: _test_cases

    def _test_cases(self):
        #
        if self.case == 100:
            nodeurl = '/services/time'
            num_iters = 200

            st = up.secs()

            for i in range(0, num_iters):
                rsp = self.server.rna_xmlrpc2.invoke(self.session,
                                                     nodeurl,'get',
                                                     )

            end = up.secs()

            print '%d gets took %f seconds.' % (num_iters,end-st)
开发者ID:mcruse,项目名称:monotone,代码行数:16,代码来源:_test_case_other.py

示例14: __init__

 def __init__(self):
     self.source = None
     self.updated = 0
     self.synclock = RLock()
     self.result = Undefined
     self.support_cov = False
     self.created = uptime.secs()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
开发者ID:mcruse,项目名称:monotone,代码行数:9,代码来源:cache.py

示例15: __init__

 def __init__(self, qid, iterator, **kw):
     self.qid = qid
     self.complete = False
     self.iterator = iterator
     self.returned = Counter()
     self.timeout = kw.get("timeout", 300)
     self.default_count = kw.get("count", 1000)
     self.created = self.touched = uptime.secs()
     super(Query, self).__init__()
开发者ID:mcruse,项目名称:monotone,代码行数:9,代码来源:manager.py


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