Python tornado.ioloop.IOLoop.clear_current() Examples

The following are 27 code examples of tornado.ioloop.IOLoop.clear_current(). 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.IOLoop , or try the search function .
Example #1
Source File: testing.py    From QCFractal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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() 
Example #2
Source File: twisted_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
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() 
Example #3
Source File: ioloop_test.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
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) 
Example #4
Source File: ioloop_test.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #5
Source File: ioloop_test.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #6
Source File: asyncio.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #7
Source File: twisted.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #8
Source File: twisted_test.py    From pySINDy with MIT License 5 votes vote down vote up
def tearDown(self):
        self.reactor.disconnectAll()
        self.io_loop.clear_current()
        self.io_loop.close(all_fds=True)
        restore_signal_handlers(self.saved_signals) 
Example #9
Source File: twisted_test.py    From pySINDy with MIT License 5 votes vote down vote up
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() 
Example #10
Source File: ioloop_test.py    From pySINDy with MIT License 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #11
Source File: twisted.py    From pySINDy with MIT License 5 votes vote down vote up
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() 
Example #12
Source File: twisted.py    From pySINDy with MIT License 5 votes vote down vote up
def __init__(self):
        # always use a new ioloop
        IOLoop.clear_current()
        IOLoop(make_current=True)
        super(_TestReactor, self).__init__()
        IOLoop.clear_current() 
Example #13
Source File: test_future.py    From pySINDy with MIT License 5 votes vote down vote up
def tearDown(self):
        super(TestFutureSocket, self).tearDown()
        if self.loop:
            self.loop.close(all_fds=True)
        IOLoop.clear_current()
        IOLoop.clear_instance() 
Example #14
Source File: test_ioloop.py    From pySINDy with MIT License 5 votes vote down vote up
def tearDown(self):
        super(TestIOLoop, self).tearDown()
        BaseIOLoop.clear_current()
        BaseIOLoop.clear_instance() 
Example #15
Source File: twisted.py    From tornado-zh with MIT License 5 votes vote down vote up
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() 
Example #16
Source File: ioloop_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
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) 
Example #17
Source File: ioloop_test.py    From teleport with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #18
Source File: twisted.py    From teleport with Apache License 2.0 5 votes vote down vote up
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() 
Example #19
Source File: twisted.py    From teleport with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        # always use a new ioloop
        IOLoop.clear_current()
        IOLoop(make_current=True)
        super(_TestReactor, self).__init__()
        IOLoop.clear_current() 
Example #20
Source File: test_future.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def tearDown(self):
        super(TestFutureSocket, self).tearDown()
        if self.loop:
            self.loop.close(all_fds=True)
        IOLoop.clear_current()
        IOLoop.clear_instance() 
Example #21
Source File: test_ioloop.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def tearDown(self):
        super(TestIOLoop, self).tearDown()
        BaseIOLoop.clear_current()
        BaseIOLoop.clear_instance() 
Example #22
Source File: ioloop_test.py    From opendevops with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #23
Source File: ioloop_test.py    From opendevops with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #24
Source File: asyncio.py    From tornado-zh with MIT License 5 votes vote down vote up
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() 
Example #25
Source File: twisted.py    From tornado-zh with MIT License 5 votes vote down vote up
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() 
Example #26
Source File: ioloop_test.py    From tornado-zh with MIT License 5 votes vote down vote up
def setUp(self):
        self.io_loop = None
        IOLoop.clear_current() 
Example #27
Source File: asyncio.py    From tornado-zh with MIT License 5 votes vote down vote up
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()