當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。