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


Python POLLER.sched方法代码示例

本文整理汇总了Python中neubot.poller.POLLER.sched方法的典型用法代码示例。如果您正苦于以下问题:Python POLLER.sched方法的具体用法?Python POLLER.sched怎么用?Python POLLER.sched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neubot.poller.POLLER的用法示例。


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

示例1: _waiting_rawtest

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _waiting_rawtest(self, stream, data):
     ''' Waiting for RAWTEST message from client '''
     context = stream.opaque
     context.bufferise(data)
     tmp = context.pullup(len(RAWTEST))
     if not tmp:
         stream.recv(len(RAWTEST), self._waiting_rawtest)
         return
     if tmp[4:5] == PING_CODE:
         logging.debug('< PING')
         stream.send(PINGBACK, self._sent_pingback)
         logging.debug('> PINGBACK')
         return
     if tmp[4:5] != RAWTEST_CODE:
         raise RuntimeError('raw_srvr: received invalid message')
     logging.debug('< RAWTEST')
     logging.info('raw_srvr: waiting for RAWTEST message... complete')
     logging.info('raw_srvr: raw test... in progress')
     context.count = context.snap_count = stream.bytes_out
     context.ticks = context.snap_ticks = utils.ticks()
     context.snap_utime, context.snap_stime = os.times()[:2]
     message = PIECE_CODE + context.auth * int(LEN_MESSAGE / AUTH_LEN)
     context.message = struct.pack('!I', len(message)) + message
     stream.send(context.message, self._piece_sent)
     #logging.debug('> PIECE')
     POLLER.sched(1, self._periodic, stream)
     stream.recv(1, self._waiting_eof)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:29,代码来源:raw_srvr.py

示例2: _periodic

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _periodic(self, args):
     """ Periodically snap goodput """
     stream = args[0]
     if stream.opaque:
         deferred = Deferred()
         deferred.add_callback(self._periodic_internal)
         deferred.add_errback(lambda err: self._periodic_error(stream, err))
         deferred.callback(stream)
         POLLER.sched(1, self._periodic, stream)
开发者ID:neubot,项目名称:neubot,代码行数:11,代码来源:raw_clnt.py

示例3: _schedule_after

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _schedule_after(self, interval):
     ''' Schedule next rendezvous after interval seconds '''
     logging.info('background_rendezvous: next rendezvous in %d seconds',
                  interval)
     timestamp = POLLER.sched(interval, self.run)
     STATE.update('idle', publish=False)
     STATE.update('next_rendezvous', timestamp)
开发者ID:servetti-polito,项目名称:neubot-dash,代码行数:9,代码来源:background_rendezvous.py

示例4: _waiting_piece

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _waiting_piece(self, stream, data):
     ''' Invoked when new data is available '''
     # Note: this loop cannot be adapted to process other messages
     # easily, as pointed out in <skype_defs.py>.
     context = stream.opaque
     context.bufferise(data)
     context.state['rcvr_data'].append((utils.ticks(), len(data)))
     while True:
         if context.left > 0:
             context.left = context.skip(context.left)
             if context.left > 0:
                 break
         elif context.left == 0:
             tmp = context.pullup(4)
             if not tmp:
                 break
             context.left, = struct.unpack('!I', tmp)
             if context.left > MAXRECV:
                 raise RuntimeError('skype_clnt: PIECE too large')
             if not context.ticks:
                 context.ticks = context.snap_ticks = utils.ticks()
                 context.count = context.snap_count = stream.bytes_in
                 context.snap_utime, context.snap_stime = os.times()[:2]
                 POLLER.sched(1, self._periodic, stream)
             if context.left == 0:
                 logging.debug('< {empty-message}')
                 logging.info('skype_clnt: skype goodput test... complete')
                 ticks = utils.ticks()
                 timediff = ticks - context.ticks
                 bytesdiff = stream.bytes_in - context.count
                 context.state['goodput'] = {
                                             'ticks': ticks,
                                             'bytesdiff': bytesdiff,
                                             'timediff': timediff,
                                            }
                 if timediff > 1e-06:
                     speed = utils.speed_formatter(bytesdiff / timediff)
                     logging.info('skype_clnt: goodput: %s', speed)
                     STATE.update('test_download', speed, publish=0)
                     STATE.update('test_upload', 'N/A')
                 self._periodic_internal(stream)
                 context.state['complete'] = 1
                 stream.close()
                 return
         else:
             raise RuntimeError('skype_clnt: internal error')
     stream.recv(MAXRECV, self._waiting_piece)
开发者ID:claudiuperta,项目名称:neubot,代码行数:49,代码来源:skype_clnt.py

示例5: _periodic

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
    def _periodic(self):
        ''' Periodically generate notification for old events '''
        POLLER.sched(INTERVAL, self._periodic)
        self._tofire, queue = [], self._tofire
        for event in queue:

            #
            # WARNING! Please resist the temptation of merging
            # the [] and the del into a single pop() because that
            # will not work: this is a defaultdict and so here
            # event might not be in _subscribers.
            #
            queue = self._subscribers[event]
            del self._subscribers[event]

            logging.debug("notify: periodically publish event: %s", event)

            self._fireq(event, queue)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:20,代码来源:notify.py

示例6: _waiting_piece

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _waiting_piece(self, stream, data):
     """ Invoked when new data is available """
     # Note: this loop cannot be adapted to process other messages
     # easily, as pointed out in <raw_defs.py>.
     context = stream.opaque
     context.bufferise(data)
     context.state["rcvr_data"].append((utils.ticks(), len(data)))
     while True:
         if context.left > 0:
             context.left = context.skip(context.left)
             if context.left > 0:
                 break
         elif context.left == 0:
             tmp = context.pullup(4)
             if not tmp:
                 break
             context.left, = struct.unpack("!I", tmp)
             if context.left > MAXRECV:
                 raise RuntimeError("raw_clnt: PIECE too large")
             if not context.ticks:
                 context.ticks = context.snap_ticks = utils.ticks()
                 context.count = context.snap_count = stream.bytes_in
                 context.snap_utime, context.snap_stime = os.times()[:2]
                 POLLER.sched(1, self._periodic, stream)
             if context.left == 0:
                 logging.debug("< {empty-message}")
                 logging.info("raw_clnt: raw goodput test... complete")
                 ticks = utils.ticks()
                 timediff = ticks - context.ticks
                 bytesdiff = stream.bytes_in - context.count
                 context.state["goodput"] = {"ticks": ticks, "bytesdiff": bytesdiff, "timediff": timediff}
                 if timediff > 1e-06:
                     speed = utils.speed_formatter(bytesdiff / timediff)
                     logging.info("raw_clnt: goodput: %s", speed)
                     STATE.update("test_progress", "100%", publish=False)
                     STATE.update("test_download", speed, publish=0)
                     STATE.update("test_upload", "N/A")
                 self._periodic_internal(stream)
                 context.state["complete"] = 1
                 stream.close()
                 return
         else:
             raise RuntimeError("raw_clnt: internal error")
     stream.recv(MAXRECV, self._waiting_piece)
开发者ID:neubot,项目名称:neubot,代码行数:46,代码来源:raw_clnt.py

示例7: _schedule_after

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _schedule_after(self, interval):
     """ Schedule next rendezvous after interval seconds """
     logging.info("background_rendezvous: next rendezvous in %d seconds", interval)
     timestamp = POLLER.sched(interval, self.run)
     STATE.update("idle", publish=False)
     STATE.update("next_rendezvous", timestamp)
开发者ID:neubot,项目名称:neubot,代码行数:8,代码来源:background_rendezvous.py

示例8: __init__

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def __init__(self):
     self._timestamps = collections.defaultdict(int)
     self._subscribers = collections.defaultdict(list)
     self._tofire = []
     POLLER.sched(INTERVAL, self._periodic)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:7,代码来源:notify.py

示例9: _schedule

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _schedule(self):
     ''' Schedule next check for updates '''
     interval = CONFIG['win32_updater_interval']
     logging.debug('updater_runner: next check in %d seconds',
                   interval)
     POLLER.sched(interval, self.retrieve_versioninfo)
开发者ID:servetti-polito,项目名称:neubot-dash,代码行数:8,代码来源:updater_runner.py

示例10: _schedule

# 需要导入模块: from neubot.poller import POLLER [as 别名]
# 或者: from neubot.poller.POLLER import sched [as 别名]
 def _schedule(self):
     ''' Schedule next check for updates '''
     # TODO remember to raise this to 1800 seconds
     POLLER.sched(60, self.retrieve_versioninfo)
开发者ID:felipebusnello,项目名称:neubot,代码行数:6,代码来源:updater_runner.py


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