Python tornado.ioloop.start() Examples
The following are 30
code examples of tornado.ioloop.start().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.ioloop
, or try the search function
.
Example #1
Source File: backend_webagg.py From CogAlg with MIT License | 6 votes |
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')
Example #2
Source File: ioloop.py From enaml-native with MIT License | 6 votes |
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()
Example #3
Source File: ipc.py From cachebrowser with MIT License | 6 votes |
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
Example #4
Source File: ioloop.py From enaml-native with MIT License | 6 votes |
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()
Example #5
Source File: backend_webagg.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
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')
Example #6
Source File: __init__.py From bugbuzz-python with MIT License | 6 votes |
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
Example #7
Source File: backend_webagg.py From coffeegrindsize with MIT License | 6 votes |
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')
Example #8
Source File: ioloop.py From pySINDy with MIT License | 6 votes |
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()
Example #9
Source File: __init__.py From bugbuzz-python with MIT License | 6 votes |
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
Example #10
Source File: ioloop.py From vnpy_crypto with MIT License | 6 votes |
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()
Example #11
Source File: webserver.py From beancount-import with GNU General Public License v2.0 | 6 votes |
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()
Example #12
Source File: ioloop.py From tornado-zh with MIT License | 6 votes |
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()
Example #13
Source File: init.py From RobotAIEngine with Apache License 2.0 | 6 votes |
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()
Example #14
Source File: backend_webagg.py From GraphicDesignPatternByPython with MIT License | 6 votes |
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')
Example #15
Source File: ioloop.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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()
Example #16
Source File: ioloop.py From tornado-zh with MIT License | 6 votes |
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()
Example #17
Source File: backend_webagg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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')
Example #18
Source File: ioloop.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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()
Example #19
Source File: _background_server.py From colabtools with Apache License 2.0 | 5 votes |
def __init__(self, app): """Initialize (but do not start) background server. Args: app: server application to run. """ self._app = app # These will be initialized when starting the server. self._port = None self._server_thread = None self._ioloop = None self._server = None
Example #20
Source File: http_download.py From honeything with GNU General Public License v3.0 | 5 votes |
def main(): ioloop = tornado.ioloop.IOLoop.instance() dl = HttpDownload(ioloop) url = len(sys.argv) > 1 and sys.argv[1] or 'http://www.google.com/' username = len(sys.argv) > 2 and sys.argv[2] password = len(sys.argv) > 3 and sys.argv[3] #print 'using URL: %s' % url ht.logger.info('using URL: %s' % url) dl.download(url=url, username=username, password=password, delay_seconds=0) ioloop.start()
Example #21
Source File: backend_webagg.py From CogAlg with MIT License | 5 votes |
def show(): WebAggApplication.initialize() url = "http://{address}:{port}{prefix}".format( address=WebAggApplication.address, port=WebAggApplication.port, prefix=WebAggApplication.url_prefix) if rcParams['webagg.open_in_browser']: import webbrowser webbrowser.open(url) else: print("To view figure, visit {0}".format(url)) WebAggApplication.start()
Example #22
Source File: ioloop.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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()
Example #23
Source File: backend_webagg.py From coffeegrindsize with MIT License | 5 votes |
def run(self): tornado.ioloop.IOLoop.instance().start()
Example #24
Source File: ioloop.py From pySINDy with MIT License | 5 votes |
def start(self): """Starts the timer.""" self._running = True self._next_timeout = self.io_loop.time() self._schedule_next()
Example #25
Source File: ioloop.py From pySINDy with MIT License | 5 votes |
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()
Example #26
Source File: ioloop.py From pySINDy with MIT License | 5 votes |
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()
Example #27
Source File: ioloop.py From pySINDy with MIT License | 5 votes |
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()
Example #28
Source File: webserver.py From beancount-import with GNU General Public License v2.0 | 5 votes |
def start_check_modification_observer(self, loaded_reconciler): if self.check_modification_observer is not None: self.check_modification_observer.unschedule_all() self.check_modification_observer = watchdog.observers.Observer() handler = JournalModificationHandler(self) journal_paths = set( os.path.dirname(filename) for filename in loaded_reconciler.editor.journal_filenames) for path in journal_paths: self.check_modification_observer.schedule(handler, path) self.check_modification_observer.start()
Example #29
Source File: __main__.py From spyder-terminal with MIT License | 5 votes |
def main(port, shell): """Create and setup a new tornado server.""" LOGGER.info("Server is now at: 127.0.0.1:{}".format(port)) LOGGER.info('Shell: {0}'.format(shell)) application = create_app(shell) ioloop = tornado.ioloop.IOLoop.instance() application.listen(port, address='127.0.0.1') try: ioloop.start() except KeyboardInterrupt: pass finally: LOGGER.info("Closing server...\n") application.term_manager.shutdown() tornado.ioloop.IOLoop.instance().stop()
Example #30
Source File: backend_webagg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show(): WebAggApplication.initialize() url = "http://127.0.0.1:{port}{prefix}".format( port=WebAggApplication.port, prefix=WebAggApplication.url_prefix) if rcParams['webagg.open_in_browser']: import webbrowser webbrowser.open(url) else: print("To view figure, visit {0}".format(url)) WebAggApplication.start()