From: Ben Darnell Date: Sun, 21 Jan 2018 19:01:42 +0000 (-0500) Subject: ioloop: Remove IOLoop.initialized() X-Git-Tag: v5.0.0~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2252%2Fhead;p=thirdparty%2Ftornado.git ioloop: Remove IOLoop.initialized() It is no longer possible to provide this method with reasonable semantics. --- diff --git a/docs/ioloop.rst b/docs/ioloop.rst index fb41f2d65..2c5fdc2cd 100644 --- a/docs/ioloop.rst +++ b/docs/ioloop.rst @@ -19,7 +19,6 @@ .. automethod:: IOLoop.run_sync .. automethod:: IOLoop.close .. automethod:: IOLoop.instance - .. automethod:: IOLoop.initialized .. automethod:: IOLoop.install .. automethod:: IOLoop.clear_instance diff --git a/docs/releases/v5.0.0.rst b/docs/releases/v5.0.0.rst index 8d9b56ba6..e9633fe83 100644 --- a/docs/releases/v5.0.0.rst +++ b/docs/releases/v5.0.0.rst @@ -167,8 +167,8 @@ Other notes - ``tornado.ioloop.TimeoutError`` is now an alias for `tornado.util.TimeoutError`. - `.IOLoop.instance` is now a deprecated alias for `.IOLoop.current`. -- `.IOLoop.initialized`, `.IOLoop.install`, and - `.IOLoop.clear_instance` are all deprecated. +- `.IOLoop.install` and `.IOLoop.clear_instance` are deprecated. +- ``IOLoop.initialized`` has been removed. - On Python 3, the `asyncio`-backed `.IOLoop` is always used and alternative `.IOLoop` implementations cannot be configured. - `~.IOLoop.run_sync` cancels its argument on a timeout. This diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 2e09b32b9..493cbea94 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -221,29 +221,6 @@ class IOLoop(Configurable): """ return IOLoop.current() - @staticmethod - def initialized(): - """Returns true if there is a current IOLoop. - - .. versionchanged:: 5.0 - - Redefined in terms of `current()` instead of `instance()`. - - .. deprecated:: 5.0 - - This method only knows about `IOLoop` objects (and not, for - example, `asyncio` event loops), so it is of limited use. - """ - if asyncio is None: - return IOLoop.current(instance=False) is not None - else: - # Asyncio gives us no way to ask whether an instance - # exists without creating one. Even calling - # `IOLoop.current(instance=False)` will create the asyncio - # loop (but not the Tornado loop, which would break the - # ability to use this function for "is it safe to fork?". - return False - def install(self): """Deprecated alias for `make_current()`. diff --git a/tornado/process.py b/tornado/process.py index cedea40aa..122fd7e14 100644 --- a/tornado/process.py +++ b/tornado/process.py @@ -125,10 +125,6 @@ def fork_processes(num_processes, max_restarts=100): assert _task_id is None if num_processes is None or num_processes <= 0: num_processes = cpu_count() - if ioloop.IOLoop.initialized(): - raise RuntimeError("Cannot run in multiple processes: IOLoop instance " - "has already been initialized. You cannot call " - "IOLoop.instance() before calling start_processes()") gen_log.info("Starting %d processes", num_processes) children = {} diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index 638613e4f..4589e51bc 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -66,7 +66,6 @@ class ProcessTest(unittest.TestCase): # place for it). skip_if_twisted() with ExpectLog(gen_log, "(Starting .* processes|child .* exited|uncaught exception)"): - self.assertFalse(IOLoop.initialized()) sock, port = bind_unused_port() def get_url(path):