.. automethod:: IOLoop.run_sync
.. automethod:: IOLoop.close
.. automethod:: IOLoop.instance
- .. automethod:: IOLoop.initialized
.. automethod:: IOLoop.install
.. automethod:: IOLoop.clear_instance
- ``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
"""
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()`.
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 = {}
# 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):