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


Python tornado.autoreload方法代码示例

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


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

示例1: start

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def start(check_time: int = 500) -> None:
    """Begins watching source files for changes.

    .. versionchanged:: 5.0
       The ``io_loop`` argument (deprecated since version 4.1) has been removed.
    """
    io_loop = ioloop.IOLoop.current()
    if io_loop in _io_loops:
        return
    _io_loops[io_loop] = True
    if len(_io_loops) > 1:
        gen_log.warning("tornado.autoreload started more than once in the same process")
    modify_times = {}  # type: Dict[str, float]
    callback = functools.partial(_reload_on_update, modify_times)
    scheduler = ioloop.PeriodicCallback(callback, check_time)
    scheduler.start() 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:18,代码来源:autoreload.py

示例2: start

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def start(check_time=500):
    """Begins watching source files for changes.

    .. versionchanged:: 5.0
       The ``io_loop`` argument (deprecated since version 4.1) has been removed.
    """
    io_loop = ioloop.IOLoop.current()
    if io_loop in _io_loops:
        return
    _io_loops[io_loop] = True
    if len(_io_loops) > 1:
        gen_log.warning("tornado.autoreload started more than once in the same process")
    modify_times = {}
    callback = functools.partial(_reload_on_update, modify_times)
    scheduler = ioloop.PeriodicCallback(callback, check_time)
    scheduler.start() 
开发者ID:tp4a,项目名称:teleport,代码行数:18,代码来源:autoreload.py

示例3: __init__

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def __init__(self,instance,host="localhost",port=None,autoreload=False):
        super(WebServer, self).__init__()
        self.app=None
        self.instance=instance
        self.host=host
        self.autoreload=autoreload

        if port is not None:
            self.port = port

        while not isFree("localhost", self.port):
            self.port += 1

        self.instance._webserver=(self.host,self.port)

        try: # https://bugs.python.org/issue37373 FIX: tornado/py3.8 on windows
            if sys.platform == 'win32':
                asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
        except:
            pass 
开发者ID:manatlan,项目名称:guy,代码行数:22,代码来源:guy.py

示例4: tearDown

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def tearDown(self):
        if (not IOLoop.initialized() or
            self.io_loop is not IOLoop.instance()):
            # Try to clean up any file descriptors left open in the ioloop.
            # This avoids leaks, especially when tests are run repeatedly
            # in the same process with autoreload (because curl does not
            # set FD_CLOEXEC on its file descriptors)
            self.io_loop.close(all_fds=True)
        super(AsyncTestCase, self).tearDown() 
开发者ID:omererdem,项目名称:honeything,代码行数:11,代码来源:testing.py

示例5: __init__

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def __init__(self, auto_reload=True, port=8888):
        self.app = MyApplication(autoreload=True)
        self.auto_reload = auto_reload
        self.port = port
        logger.info("started server " + str(port) + (" with autoreload mode" if self.auto_reload else "")) 
开发者ID:knightliao,项目名称:pfrock,代码行数:7,代码来源:__init__.py

示例6: add_watch

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def add_watch(self, watch_file):
        tornado.autoreload.watch(watch_file) 
开发者ID:knightliao,项目名称:pfrock,代码行数:4,代码来源:__init__.py

示例7: run

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def run(self,log=False,autoreload=False,one=False,args=[]):
        """ Run the guy's app in a windowed env (one client)"""
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        if ISANDROID: #TODO: add executable for kivy/iOs mac/apple
            runAndroid(self)
        else:
            lockPort=None
            if one:
                lp=LockPortFile(self._name)
                if lp.bringToFront():
                    return
                else:
                    lockPort = lp.create()

            ws=WebServer( self, autoreload=autoreload )
            ws.start()

            app=ChromeApp(ws.startPage,self._name,self.size,lockPort=lockPort,chromeargs=args)

            self.RETOUR=None
            def exit(v=None):
                self.RETOUR=v

                ws.exit()
                app.exit()

            tornado.autoreload.add_reload_hook(exit)

            self._callbackExit = exit
            try:
                app.wait() # block
            except KeyboardInterrupt:
                print("-Process stopped")

            ws.exit()
            ws.join()
            return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:43,代码来源:guy.py

示例8: runCef

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def runCef(self,log=False,autoreload=False,one=False):
        """ Run the guy's app in a windowed cefpython3 (one client)"""
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        lockPort=None
        if one:
            lp=LockPortFile(self._name)
            if lp.bringToFront():
                return
            else:
                lockPort = lp.create()

        ws=WebServer( self, autoreload=autoreload )
        ws.start()

        self.RETOUR=None
        try:
            app=CefApp(ws.startPage,self.size,lockPort=lockPort)

            def cefexit(v=None):
                self.RETOUR=v
                app.exit()

            tornado.autoreload.add_reload_hook(app.exit)

            self._callbackExit = cefexit
            try:
                app.wait() # block
            except KeyboardInterrupt:
                print("-Process stopped")
        except Exception as e:
            print("Trouble with CEF:",e)
        ws.exit()
        ws.join()
        return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:40,代码来源:guy.py

示例9: serve

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def serve(self,port=8000,log=False,open=True,autoreload=False):
        """ Run the guy's app for multiple clients (web/server mode) """
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        ws=WebServer( self ,"0.0.0.0",port=port, autoreload=autoreload )
        ws.start()

        self.RETOUR=None
        def exit(v=None):
            self.RETOUR=v
            ws.exit()

        self._callbackExit = exit
        print("Running", ws.startPage )

        if open: #auto open browser
            try:
                import webbrowser
                webbrowser.open_new_tab(ws.startPage)
            except:
                pass

        try:
            ws.join() #important !
        except KeyboardInterrupt:
            print("-Process stopped")
        ws.exit()
        return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:33,代码来源:guy.py

示例10: _reload

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def _reload() -> None:
    global _reload_attempted
    _reload_attempted = True
    for fn in _reload_hooks:
        fn()
    if hasattr(signal, "setitimer"):
        # Clear the alarm signal set by
        # ioloop.set_blocking_log_threshold so it doesn't fire
        # after the exec.
        signal.setitimer(signal.ITIMER_REAL, 0, 0)
    # sys.path fixes: see comments at top of file.  If __main__.__spec__
    # exists, we were invoked with -m and the effective path is about to
    # change on re-exec.  Reconstruct the original command line to
    # ensure that the new process sees the same path we did.  If
    # __spec__ is not available (Python < 3.4), check instead if
    # sys.path[0] is an empty string and add the current directory to
    # $PYTHONPATH.
    if _autoreload_is_main:
        assert _original_argv is not None
        spec = _original_spec
        argv = _original_argv
    else:
        spec = getattr(sys.modules["__main__"], "__spec__", None)
        argv = sys.argv
    if spec:
        argv = ["-m", spec.name] + argv[1:]
    else:
        path_prefix = "." + os.pathsep
        if sys.path[0] == "" and not os.environ.get("PYTHONPATH", "").startswith(
            path_prefix
        ):
            os.environ["PYTHONPATH"] = path_prefix + os.environ.get("PYTHONPATH", "")
    if not _has_execv:
        subprocess.Popen([sys.executable] + argv)
        os._exit(0)
    else:
        try:
            os.execv(sys.executable, [sys.executable] + argv)
        except OSError:
            # Mac OS X versions prior to 10.6 do not support execv in
            # a process that contains multiple threads.  Instead of
            # re-executing in the current process, start a new one
            # and cause the current process to exit.  This isn't
            # ideal since the new process is detached from the parent
            # terminal and thus cannot easily be killed with ctrl-C,
            # but it's better than not being able to autoreload at
            # all.
            # Unfortunately the errno returned in this case does not
            # appear to be consistent, so we can't easily check for
            # this error specifically.
            os.spawnv(  # type: ignore
                os.P_NOWAIT, sys.executable, [sys.executable] + argv
            )
            # At this point the IOLoop has been closed and finally
            # blocks will experience errors if we allow the stack to
            # unwind, so just exit uncleanly.
            os._exit(0) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:59,代码来源:autoreload.py

示例11: _reload

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import autoreload [as 别名]
def _reload():
    global _reload_attempted
    _reload_attempted = True
    for fn in _reload_hooks:
        fn()
    if hasattr(signal, "setitimer"):
        # Clear the alarm signal set by
        # ioloop.set_blocking_log_threshold so it doesn't fire
        # after the exec.
        signal.setitimer(signal.ITIMER_REAL, 0, 0)
    # sys.path fixes: see comments at top of file.  If __main__.__spec__
    # exists, we were invoked with -m and the effective path is about to
    # change on re-exec.  Reconstruct the original command line to
    # ensure that the new process sees the same path we did.  If
    # __spec__ is not available (Python < 3.4), check instead if
    # sys.path[0] is an empty string and add the current directory to
    # $PYTHONPATH.
    if _autoreload_is_main:
        spec = _original_spec
        argv = _original_argv
    else:
        spec = getattr(sys.modules['__main__'], '__spec__', None)
        argv = sys.argv
    if spec:
        argv = ['-m', spec.name] + argv[1:]
    else:
        path_prefix = '.' + os.pathsep
        if (sys.path[0] == '' and
                not os.environ.get("PYTHONPATH", "").startswith(path_prefix)):
            os.environ["PYTHONPATH"] = (path_prefix +
                                        os.environ.get("PYTHONPATH", ""))
    if not _has_execv:
        subprocess.Popen([sys.executable] + argv)
        os._exit(0)
    else:
        try:
            os.execv(sys.executable, [sys.executable] + argv)
        except OSError:
            # Mac OS X versions prior to 10.6 do not support execv in
            # a process that contains multiple threads.  Instead of
            # re-executing in the current process, start a new one
            # and cause the current process to exit.  This isn't
            # ideal since the new process is detached from the parent
            # terminal and thus cannot easily be killed with ctrl-C,
            # but it's better than not being able to autoreload at
            # all.
            # Unfortunately the errno returned in this case does not
            # appear to be consistent, so we can't easily check for
            # this error specifically.
            os.spawnv(os.P_NOWAIT, sys.executable, [sys.executable] + argv)
            # At this point the IOLoop has been closed and finally
            # blocks will experience errors if we allow the stack to
            # unwind, so just exit uncleanly.
            os._exit(0) 
开发者ID:tp4a,项目名称:teleport,代码行数:56,代码来源:autoreload.py


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