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


Python ioloop.start方法代码示例

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


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

示例1: stop

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def stop(self):
        """Stop the I/O loop.

        If the event loop is not currently running, the next call to `start()`
        will return immediately.

        To use asynchronous methods from otherwise-synchronous code (such as
        unit tests), you can start and stop the event loop like this::

          ioloop = IOLoop()
          async_method(ioloop=ioloop, callback=ioloop.stop)
          ioloop.start()

        ``ioloop.start()`` will return after ``async_method`` has run
        its callback, whether that callback was invoked before or
        after ``ioloop.start``.

        Note that even after `stop` has been called, the `IOLoop` is not
        completely stopped until `IOLoop.start` has also returned.
        Some work that was scheduled before the call to `stop` may still
        be run before the `IOLoop` shuts down.
        """
        raise NotImplementedError() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:25,代码来源:ioloop.py

示例2: _request_async

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def _request_async(self, request, callback=None, error=None, single=False, timeout=5):
        global _urllib_request
        ## Build URL
        url = self.getUrl(request)
        if single is True:
            id = time.time()
            client = HTTPClient(self, url=url, urllib_func=_urllib_request,
                                callback=None, error=None, id=id, timeout=timeout)
            with self.latest_sub_callback_lock:
                self.latest_sub_callback['id'] = id
                self.latest_sub_callback['callback'] = callback
                self.latest_sub_callback['error'] = error
        else:
            client = HTTPClient(self, url=url, urllib_func=_urllib_request,
                                callback=callback, error=error, timeout=timeout)

        thread = threading.Thread(target=client.run)
        thread.daemon = self.daemon
        thread.start()

        def abort():
            client.cancel()
        return abort 
开发者ID:fangpenlin,项目名称:bugbuzz-python,代码行数:25,代码来源:__init__.py

示例3: ipython_inline_display

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def ipython_inline_display(figure):
    import tornado.template

    WebAggApplication.initialize()
    if not webagg_server_thread.is_alive():
        webagg_server_thread.start()

    fignum = figure.number
    tpl = Path(core.FigureManagerWebAgg.get_static_file_path(),
               "ipython_inline_figure.html").read_text()
    t = tornado.template.Template(tpl)
    return t.generate(
        prefix=WebAggApplication.url_prefix,
        fig_id=fignum,
        toolitems=core.NavigationToolbar2WebAgg.toolitems,
        canvas=figure.canvas,
        port=WebAggApplication.port).decode('utf-8') 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:19,代码来源:backend_webagg.py

示例4: main

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def main(argv, **kwargs):
    args = parse_arguments(argv, **kwargs)
    logging_args = dict(level=args.loglevel)
    if args.log_output is not None:
        logging_args['filename'] = args.log_output
    logging.basicConfig(**logging_args)
    
    init_tornado_asyncio()

    ioloop = tornado.ioloop.IOLoop.instance()
    app = Application(args=args, ioloop=ioloop, debug=(args.loglevel == logging.DEBUG))

    http_server = tornado.httpserver.HTTPServer(app)
    sockets = tornado.netutil.bind_sockets(
        port=args.port or None, address=args.address)
    http_server.add_sockets(sockets)
    server_url = 'http://%s:%s' % sockets[0].getsockname()[0:2]
    print('Listening at %s' % server_url)
    if args.browser:
        webbrowser.open(server_url, new=1)
    ioloop.start() 
开发者ID:jbms,项目名称:beancount-import,代码行数:23,代码来源:webserver.py

示例5: initialize_websocket_server

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def initialize_websocket_server(self, port):
        app = tornado.web.Application([
            (r'/', WebSocketIPCClient, {'router': self.router}),
        ])

        def run_loop():
            logger.debug("Starting IPC websocket server on port {}".format(port))
            ioloop = tornado.ioloop.IOLoop()
            ioloop.make_current()
            app.listen(port)
            ioloop.start()

        t = Thread(target=run_loop)
        t.daemon = True
        t.start()

        return app 
开发者ID:CacheBrowser,项目名称:cachebrowser,代码行数:19,代码来源:ipc.py

示例6: _setup_logging

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def _setup_logging(self):
        """The IOLoop catches and logs exceptions, so it's
        important that log output be visible.  However, python's
        default behavior for non-root loggers (prior to python
        3.2) is to print an unhelpful "no handlers could be
        found" message rather than the actual log entry, so we
        must explicitly configure logging if we've made it this
        far without anything.

        This method should be called from start() in subclasses.
        """
        pass
        # if not any([logging.getLogger().handlers,
        #             logging.getLogger('tornado').handlers,
        #             logging.getLogger('tornado.application').handlers]):
        #     logging.basicConfig() 
开发者ID:codelv,项目名称:enaml-native,代码行数:18,代码来源:ioloop.py

示例7: main

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def main():
    ''' main 函数
    '''
    # 开启 search_engin_server
    ioloop = tornado.ioloop.IOLoop.instance()
    server = tornado.httpserver.HTTPServer(Application(), xheaders=True)
    server.listen(options.port)

    def sig_handler(sig, _):
        ''' 信号接收函数
        '''
        logging.warn("Caught signal: %s", sig)
        shutdown(ioloop, server)

    signal.signal(signal.SIGTERM, sig_handler)
    signal.signal(signal.SIGINT, sig_handler)
    ioloop.start() 
开发者ID:JK-River,项目名称:RobotAIEngine,代码行数:19,代码来源:init.py

示例8: close

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def close(self, all_fds=False):
        """Closes the `IOLoop`, freeing any resources used.

        If ``all_fds`` is true, all file descriptors registered on the
        IOLoop will be closed (not just the ones created by the
        `IOLoop` itself).

        Many applications will only use a single `IOLoop` that runs for the
        entire lifetime of the process.  In that case closing the `IOLoop`
        is not necessary since everything will be cleaned up when the
        process exits.  `IOLoop.close` is provided mainly for scenarios
        such as unit tests, which create and destroy a large number of
        ``IOLoops``.

        An `IOLoop` must be completely stopped before it can be closed.  This
        means that `IOLoop.stop()` must be called *and* `IOLoop.start()` must
        be allowed to return before attempting to call `IOLoop.close()`.
        Therefore the call to `close` will usually appear just after
        the call to `start` rather than near the call to `stop`.

        .. versionchanged:: 3.1
           If the `IOLoop` implementation supports non-integer objects
           for "file descriptors", those objects will have their
           ``close`` method when ``all_fds`` is true.
        """
        raise NotImplementedError() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:28,代码来源:ioloop.py

示例9: start

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def start(self):
        """Starts the I/O loop.

        The loop will run until one of the callbacks calls `stop()`, which
        will make the loop stop after the current event iteration completes.
        """
        raise NotImplementedError() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:9,代码来源:ioloop.py

示例10: _setup_logging

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def _setup_logging(self):
        """The IOLoop catches and logs exceptions, so it's
        important that log output be visible.  However, python's
        default behavior for non-root loggers (prior to python
        3.2) is to print an unhelpful "no handlers could be
        found" message rather than the actual log entry, so we
        must explicitly configure logging if we've made it this
        far without anything.

        This method should be called from start() in subclasses.
        """
        if not any([logging.getLogger().handlers,
                    logging.getLogger('tornado').handlers,
                    logging.getLogger('tornado.application').handlers]):
            logging.basicConfig() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:17,代码来源:ioloop.py

示例11: add_callback

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def add_callback(self, callback, *args, **kwargs):
        if thread.get_ident() != self._thread_ident:
            # If we're not on the IOLoop's thread, we need to synchronize
            # with other threads, or waking logic will induce a race.
            with self._callback_lock:
                if self._closing:
                    return
                list_empty = not self._callbacks
                self._callbacks.append(functools.partial(
                    stack_context.wrap(callback), *args, **kwargs))
                if list_empty:
                    # If we're not in the IOLoop's thread, and we added the
                    # first callback to an empty list, we may need to wake it
                    # up (it may wake up on its own, but an occasional extra
                    # wake is harmless).  Waking up a polling IOLoop is
                    # relatively expensive, so we try to avoid it when we can.
                    self._waker.wake()
        else:
            if self._closing:
                return
            # If we're on the IOLoop's thread, we don't need the lock,
            # since we don't need to wake anyone, just add the
            # callback. Blindly insert into self._callbacks. This is
            # safe even from signal handlers because the GIL makes
            # list.append atomic. One subtlety is that if the signal
            # is interrupting another thread holding the
            # _callback_lock block in IOLoop.start, we may modify
            # either the old or new version of self._callbacks, but
            # either way will work.
            self._callbacks.append(functools.partial(
                stack_context.wrap(callback), *args, **kwargs)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:33,代码来源:ioloop.py

示例12: start

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def start(self):
        pass 
开发者ID:fangpenlin,项目名称:bugbuzz-python,代码行数:4,代码来源:__init__.py

示例13: timeout

# 需要导入模块: from tornado import ioloop [as 别名]
# 或者: from tornado.ioloop import start [as 别名]
def timeout(self, interval, func):
        def cb():
            time.sleep(interval)
            func()
        thread = threading.Thread(target=cb)
        thread.daemon = self.daemon
        thread.start() 
开发者ID:fangpenlin,项目名称:bugbuzz-python,代码行数:9,代码来源:__init__.py


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