本文整理匯總了Python中tornado.ioloop.IOLoop.clear_current方法的典型用法代碼示例。如果您正苦於以下問題:Python IOLoop.clear_current方法的具體用法?Python IOLoop.clear_current怎麽用?Python IOLoop.clear_current使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.ioloop.IOLoop
的用法示例。
在下文中一共展示了IOLoop.clear_current方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pristine_loop
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def pristine_loop():
"""
Builds a clean IOLoop for using as a background request.
Courtesy of Dask Distributed
"""
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 (ValueError, KeyError, RuntimeError):
pass
IOLoop.clear_instance()
IOLoop.clear_current()
示例2: 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()
示例3: 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()
示例4: setUp
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def setUp(self):
self.io_loop = None
IOLoop.clear_current()
示例5: test_clear_without_current
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def test_clear_without_current(self):
# If there is no current IOLoop, clear_current is a no-op (but
# should not fail). Use a thread so we see the threading.Local
# in a pristine state.
with ThreadPoolExecutor(1) as e:
yield e.submit(IOLoop.clear_current)
示例6: tearDown
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def tearDown(self):
super(TestIOLoop, self).tearDown()
BaseIOLoop.clear_current()
BaseIOLoop.clear_instance()
示例7: tearDown
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def tearDown(self):
super(TestFutureSocket, self).tearDown()
if self.loop:
self.loop.close(all_fds=True)
IOLoop.clear_current()
IOLoop.clear_instance()
示例8: __init__
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def __init__(self):
# always use a new ioloop
IOLoop.clear_current()
IOLoop(make_current=True)
super(_TestReactor, self).__init__()
IOLoop.clear_current()
示例9: setUp
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def setUp(self):
self._saved_signals = save_signal_handlers()
IOLoop.clear_current()
self._io_loop = IOLoop(make_current=True)
self._reactor = TornadoReactor()
IOLoop.clear_current()
示例10: tearDown
# 需要導入模塊: from tornado.ioloop import IOLoop [as 別名]
# 或者: from tornado.ioloop.IOLoop import clear_current [as 別名]
def tearDown(self):
self.reactor.disconnectAll()
self.io_loop.clear_current()
self.io_loop.close(all_fds=True)
restore_signal_handlers(self.saved_signals)