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


Python IOLoop.clear_current方法代码示例

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


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

示例1: init_process

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def init_process(self):
     # IOLoop cannot survive a fork or be shared across processes
     # in any way. When multiple processes are being used, each process
     # should create its own IOLoop. We should clear current IOLoop
     # if exists before os.fork.
     IOLoop.clear_current()
     super().init_process()
开发者ID:benoitc,项目名称:gunicorn,代码行数:9,代码来源:gtornado.py

示例2: tearDown

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def tearDown(self):
     self.db.close()
     try:
         os.remove(self.temp_db)
     except:
         pass
     IOLoop.clear_current()
开发者ID:Ssekhar2017,项目名称:ipyparallel,代码行数:9,代码来源:test_db.py

示例3: test_sync_closed_loop

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
def test_sync_closed_loop():
    loop = IOLoop.current()
    loop.close()
    IOLoop.clear_current()
    IOLoop.clear_instance()

    with pytest.raises(RuntimeError) as exc_info:
        sync(loop, inc, 1)
    exc_info.match("IOLoop is clos(ed|ing)")
开发者ID:tomMoral,项目名称:distributed,代码行数:11,代码来源:test_utils.py

示例4: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
    def start(self):
        self.client = TCPClient()

        self.pcb = PeriodicCallback(self.send, 1000.0 / self.n)
        self.pcb.start()

        IOLoop.current().call_later(self.duration + 0.5, self.stop)
        IOLoop.current().start()
        IOLoop.clear_current()
开发者ID:svenkreiss,项目名称:pysparkling,代码行数:11,代码来源:tcpperf_client.py

示例5: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
	def start(self):
		try:
			app = ftApplication(self.HANDLERS)
			server = HTTPServer(app)
			server.bind(self.PORT)
			server.start(self.PROCESS_NUM)
			IOLoop.clear_current().start()
		except Exception, msg:
			print "[tornado server start Exceptions : %s]" % msg
开发者ID:mjhans,项目名称:Develop,代码行数:11,代码来源:HTTPServer.py

示例6: atexit

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def atexit(self):
     """atexit callback"""
     if self._atexit_ran:
         return
     self._atexit_ran = True
     # run the cleanup step (in a new loop, because the interrupted one is unclean)
     IOLoop.clear_current()
     loop = IOLoop()
     loop.make_current()
     loop.run_sync(self.cleanup)
开发者ID:JuliaLangEs,项目名称:jupyterhub,代码行数:12,代码来源:app.py

示例7: _atexit

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
    def _atexit(self):
        if self._atexit_ran:
            return
        self._atexit_ran = True

        self._stats_job.stop()
        IOLoop.clear_current()
        loop = IOLoop()
        loop.make_current()
        loop.run_sync(self._cleanup)
开发者ID:rbtr,项目名称:bokeh,代码行数:12,代码来源:tornado.py

示例8: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def start(self):
     old_current = IOLoop.current(instance=False)
     try:
         self._setup_logging()
         self.make_current()
         self.reactor.run()
     finally:
         if old_current is None:
             IOLoop.clear_current()
         else:
             old_current.make_current()
开发者ID:756613351,项目名称:tornado,代码行数:13,代码来源:twisted.py

示例9: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def start(self):
     old_current = IOLoop.current(instance=False)
     try:
         self._setup_logging()
         self.make_current()
         self.asyncio_loop.run_forever()
     finally:
         if old_current is None:
             IOLoop.clear_current()
         else:
             old_current.make_current()
开发者ID:netmosquito,项目名称:tornado,代码行数:13,代码来源:asyncio.py

示例10: wrapper

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
    def wrapper(*args, **kwargs):
        loop = None
        try:
            IOLoop.clear_current()
            loop = asyncio.new_event_loop()
            asyncio.set_event_loop(loop)
            loop.run_until_complete(fn(*args, **kwargs))
        finally:
            if loop is not None:
                loop.close()

            IOLoop.clear_current()
            asyncio.set_event_loop(None)
开发者ID:tomMoral,项目名称:distributed,代码行数:15,代码来源:py3_test_asyncio.py

示例11: single_run_ws

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
def single_run_ws(url, delay=0, size=0, msgs=1):
    """Time a single websocket run"""
    buf = hexlify(os.urandom(size // 2)).decode('ascii')
    msg = json.dumps({'delay': delay, 'data': buf})

    async def go():
        ws = await websocket_connect(url.replace('http', 'ws') + '/ws')
        for i in range(msgs):
            ws.write_message(msg)
            await ws.read_message()

    asyncio.set_event_loop(asyncio.new_event_loop())
    IOLoop.clear_current()
    loop = IOLoop(make_current=True)
    loop.run_sync(go)
开发者ID:minrk,项目名称:chpbench,代码行数:17,代码来源:runner.py

示例12: pristine_loop

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
def pristine_loop():
    IOLoop.clear_instance()
    IOLoop.clear_current()
    loop = IOLoop()
    loop.make_current()
    assert IOLoop.current() is loop
    try:
        yield loop
    finally:
        try:
            loop.close(all_fds=True)
        except (KeyError, ValueError):
            pass
        IOLoop.clear_instance()
        IOLoop.clear_current()
开发者ID:tomMoral,项目名称:distributed,代码行数:17,代码来源:utils_test.py

示例13: start

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
 def start(self):
     old_current = IOLoop.current(instance=False)
     try:
         old_asyncio = asyncio.get_event_loop()
     except RuntimeError:
         old_asyncio = None
     try:
         self._setup_logging()
         self.make_current()
         # This is automatic in 3.5, but must be done manually in 3.4.
         asyncio.set_event_loop(self.asyncio_loop)
         self.asyncio_loop.run_forever()
     finally:
         if old_current is None:
             IOLoop.clear_current()
         else:
             old_current.make_current()
         asyncio.set_event_loop(old_asyncio)
开发者ID:JZQT,项目名称:tornado,代码行数:20,代码来源:asyncio.py

示例14: run

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
def run():
    io_loop = IOLoop(make_current=True)
    app = Application([("/", RootHandler)])
    port = random.randrange(options.min_port, options.max_port)
    app.listen(port, address='127.0.0.1')
    signal.signal(signal.SIGCHLD, handle_sigchld)
    args = ["ab"]
    args.extend(["-n", str(options.n)])
    args.extend(["-c", str(options.c)])
    if options.keepalive:
        args.append("-k")
    if options.quiet:
        # just stops the progress messages printed to stderr
        args.append("-q")
    args.append("http://127.0.0.1:%d/" % port)
    subprocess.Popen(args)
    io_loop.start()
    io_loop.close()
    io_loop.clear_current()
开发者ID:756613351,项目名称:tornado,代码行数:21,代码来源:benchmark.py

示例15: run_server

# 需要导入模块: from tornado.ioloop import IOLoop [as 别名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 别名]
def run_server(port, password, dbfile):
    """Start up the HTTP server. If Tornado is available it will be used, else
       fall back to the Flask debug server.
    """
    app.config['PASSWORD'] = password
    app.config['DBFILE'] = dbfile

    if USE_TORNADO:
        # When running inside an IPython Notebook, the IOLoop
        # can inherit a stale instance from the parent process,
        # so clear that.
        # https://github.com/adamgreig/sheepdog/issues/15
        # Thanks @minrk!
        if hasattr(IOLoop, '_instance'):
            del IOLoop._instance
        IOLoop.clear_current()

        HTTPServer(WSGIContainer(app)).listen(port)
        IOLoop.instance().start()
    else:
        app.run(host='0.0.0.0', port=port)
开发者ID:adamgreig,项目名称:sheepdog,代码行数:23,代码来源:server.py


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