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


Python POLLER.sched方法代码示例

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


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

示例1: test_done

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def test_done(self, *baton):
        ''' Invoked when the test is done '''

        #
        # Stop streaming test events to interested parties
        # via the log streaming API.
        # Do not stop processing immediately and give HTTP
        # code time to stream logs to the client in case
        # connections fails immediately.
        # This must not be done when we're processing the
        # somewhat internal 'rendezvous' or 'mlab-ns' tests.
        #
        if self.queue[0][0] != 'rendezvous' and self.queue[0][0] != 'mlab-ns':
            POLLER.sched(2, STREAMING_LOG.stop_streaming)

        # Paranoid
        if baton[0] != 'testdone':
            raise RuntimeError('runner_core: invoked for the wrong event')

        # Notify the caller that the test is done
        deferred, ctx = self.queue.popleft()[1:]
        deferred.callback(ctx)

        #
        # Allow for more tests
        # If callback() adds one more test, that would
        # be run by the run_queue() invocation below.
        #
        self.running = False

        # Eventually run next queued test
        self.run_queue()
开发者ID:claudiuperta,项目名称:neubot,代码行数:34,代码来源:runner_core.py

示例2: _api_exit

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def _api_exit(self, stream, request, query):
     POLLER.sched(0, POLLER.break_loop)
     response = Message()
     stringio = StringIO.StringIO("See you, space cowboy\n")
     response.compose(code="200", reason="Ok", body=stringio,
                      mimetype="text/plain", keepalive=False)
     stream.send_response(request, response)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:9,代码来源:server.py

示例3: main

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
def main(args):

    CONFIG.register_descriptions({
        "http.client.class": "Specify alternate ClientHTTP-like class",
        "http.client.method": "Specify alternate HTTP method",
        "http.client.stats": "Enable printing download stats on stdout",
        "http.client.stdout": "Enable writing response to stdout",
        "http.client.uri": "Specify URI to download from/upload to",
    })

    common.main("http.client", "Simple Neubot HTTP client", args)
    conf = CONFIG.copy()

    if conf["http.client.stats"]:
        POLLER.sched(0.5, MEASURER.start)

    make_client = TestClient
    if conf["http.client.class"]:
        make_client = utils.import_class(conf["http.client.class"])

    if not conf["http.client.uri"]:
        sys.stdout.write("Please, specify URI via -D http.client.uri=URI\n")
        sys.exit(0)

    client = make_client(POLLER)
    client.configure(conf, MEASURER)
    client.connect_uri(conf["http.client.uri"])

    POLLER.loop()
    sys.exit(0)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:32,代码来源:client.py

示例4: connection_made

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def connection_made(self):
     self.buffer = "A" * self.conf["net.stream.chunk"]
     duration = self.conf["net.stream.duration"]
     if duration >= 0:
         POLLER.sched(duration, self._do_close)
     if self.kind == "discard":
         self.start_recv()
     elif self.kind == "chargen":
         self.start_send(self.buffer)
     elif self.kind == "echo":
         self.start_recv()
     else:
         self.close()
开发者ID:DavideAllavena,项目名称:neubot,代码行数:15,代码来源:stream.py

示例5: connection_made

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def connection_made(self):
     self.buffer = "A" * self.conf.get("net.stream.chunk", 32768)
     MEASURER.register_stream(self)
     duration = self.conf.get("net.stream.duration", 10)
     if duration >= 0:
         POLLER.sched(duration, self._do_close)
     if self.kind == "discard":
         self.start_recv()
     elif self.kind == "chargen":
         self.start_send(self.buffer)
     elif self.kind == "echo":
         self.start_recv()
     else:
         self.close()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:16,代码来源:stream.py

示例6: _periodic

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def _periodic(self, *args, **kwargs):
        POLLER.sched(INTERVAL, self._periodic)
        self._tofire, q = [], self._tofire
        for event in q:

            #
            # 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("* periodic: %s", event)

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

示例7: test_done

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def test_done(self, *baton):
        ''' Invoked when the test is done '''

        #
        # Stop streaming test events to interested parties
        # via the log streaming API.
        # Do not stop processing immediately and give HTTP
        # code time to stream logs to the client in case
        # connections fails immediately.
        # This must not be done when we're processing the
        # somewhat internal 'rendezvous' test.
        #
        if self.queue[0][0] != 'rendezvous':
            POLLER.sched(2, LOG.stop_streaming)

        # Paranoid
        if baton[0] != 'testdone':
            raise RuntimeError('Invoked for the wrong event')

        # Notify the caller that the test is done
        callback, ctx = self.queue.popleft()[1:]
        try:
            if ctx:
                callback(ctx)
            else:
                callback()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            exc = asyncore.compact_traceback()
            error = str(exc)
            LOG.error('runner_core: catched exception: %s' % error)

        #
        # Allow for more tests
        # If callback() adds one more test, that would
        # be run by the run_queue() invocation below.
        #
        self.running = False

        # Eventually run next queued test
        self.run_queue()
开发者ID:felipebusnello,项目名称:neubot,代码行数:44,代码来源:runner_core.py

示例8: _do_update_queue

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def _do_update_queue(self):

        pos = 1
        for session in self.queue:
            if pos <= 3 and not session.active:
                session.active = True
            session.queuepos = pos
            pos = pos + 1

        if not self.task:
            self.task = POLLER.sched(60, self._sample_queue_length)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:13,代码来源:session.py

示例9: _schedule

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def _schedule(self):

        #
        # Typically the user does not specify the interval
        # and we use a random value around 1500 seconds.
        # The random value is extracted just once and from
        # that point on we keep using it.
        #
        interval = CONFIG["agent.interval"]
        if not interval:
            if not self._interval:
                self._interval = 1380 + random.randrange(0, 240)
            interval = self._interval

        LOG.info("* Next rendezvous in %d seconds" % interval)

        fn = lambda *args, **kwargs: self.connect_uri()
        self._task = POLLER.sched(interval, fn)

        STATE.update("idle", publish=False)
        STATE.update("next_rendezvous", self._task.timestamp)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:23,代码来源:client.py

示例10: _schedule

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def _schedule(self):

        ''' Schedule next rendezvous '''

        #
        # Typically the user does not specify the interval
        # and we use a random value around 1500 seconds.
        # The random value is extracted just once and from
        # that point on we keep using it.
        # Suggested by Elias S.G. Carotti some time ago.
        #
        interval = CONFIG["agent.interval"]
        if not interval:
            if not self._interval:
                self._interval = 1380 + random.randrange(0, 240)
            interval = self._interval

        logging.info("* Next rendezvous in %d seconds", interval)

        task = POLLER.sched(interval, self.run)

        STATE.update("idle", publish=False)
        STATE.update("next_rendezvous", task.timestamp)
开发者ID:felipebusnello,项目名称:neubot,代码行数:25,代码来源:client.py

示例11: __init__

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.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:DavideAllavena,项目名称:neubot,代码行数:8,代码来源:notify.py

示例12: use_database

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def use_database(self):
     POLLER.sched(INTERVAL, self._maintain_database)
     self._use_database = True
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:5,代码来源:log.py

示例13: _maintain_database

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
    def _maintain_database(self, *args, **kwargs):

        POLLER.sched(INTERVAL, self._maintain_database)

        if (self._use_database and not NOTIFIER.is_subscribed("testdone")):
            self._writeback()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:8,代码来源:log.py

示例14: _speedtest_check_timeout

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def _speedtest_check_timeout(self, *args, **kwargs):
     POLLER.sched(3, self._speedtest_check_timeout)
     if TRACKER.session_prune():
         NOTIFIER.publish(RENEGOTIATE)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:6,代码来源:negotiate.py

示例15: __init__

# 需要导入模块: from neubot.net.poller import POLLER [as 别名]
# 或者: from neubot.net.poller.POLLER import sched [as 别名]
 def __init__(self, poller):
     ServerHTTP.__init__(self, poller)
     self.begin_test = 0
     POLLER.sched(3, self._speedtest_check_timeout)
     self.test_server = ServerTest(poller)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:7,代码来源:negotiate.py


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