def start(io_loop=None, check_time=500):
- """Begins watching source files for changes using the given `.IOLoop`. """
+ """Begins watching source files for changes.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
+ """
io_loop = io_loop or ioloop.IOLoop.current()
if io_loop in _io_loops:
return
class YieldFuture(YieldPoint):
def __init__(self, future, io_loop=None):
+ """Adapts a `.Future` to the `YieldPoint` interface.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
+ """
self.future = future
self.io_loop = io_loop or IOLoop.current()
# or with force_instance:
client = AsyncHTTPClient(force_instance=True,
defaults=dict(user_agent="MyUserAgent"))
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
@classmethod
def configurable_base(cls):
del IOLoop._instance
@staticmethod
- def current():
+ def current(instance=True):
"""Returns the current thread's `IOLoop`.
- If an `IOLoop` is currently running or has been marked as current
- by `make_current`, returns that instance. Otherwise returns
- `IOLoop.instance()`, i.e. the main thread's `IOLoop`.
-
- A common pattern for classes that depend on ``IOLoops`` is to use
- a default argument to enable programs with multiple ``IOLoops``
- but not require the argument for simpler applications::
-
- class MyClass(object):
- def __init__(self, io_loop=None):
- self.io_loop = io_loop or IOLoop.current()
+ If an `IOLoop` is currently running or has been marked as
+ current by `make_current`, returns that instance. If there is
+ no current `IOLoop`, returns `IOLoop.instance()` (i.e. the
+ main thread's `IOLoop`, creating one if necessary) if ``instance``
+ is true.
In general you should use `IOLoop.current` as the default when
constructing an asynchronous object, and use `IOLoop.instance`
when you mean to communicate to the main thread from a different
one.
+
+ .. versionchanged:: 4.1
+ Added ``instance`` argument to control the
+
"""
current = getattr(IOLoop._current, "instance", None)
- if current is None:
+ if current is None and instance:
return IOLoop.instance()
return current
`make_current` explicitly before starting the `IOLoop`,
so that code run at startup time can find the right
instance.
+
+ .. versionchanged:: 4.1
+ An `IOLoop` created while there is no current `IOLoop`
+ will automatically become current.
"""
IOLoop._current.instance = self
return SelectIOLoop
def initialize(self):
- pass
+ if IOLoop.current(instance=False) is None:
+ self.make_current()
def close(self, all_fds=False):
"""Closes the `IOLoop`, freeing any resources used.
The callback is called every ``callback_time`` milliseconds.
`start` must be called after the `PeriodicCallback` is created.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def __init__(self, callback, callback_time, io_loop=None):
self.callback = callback
"""`BaseIOStream` constructor.
:arg io_loop: The `.IOLoop` to use; defaults to `.IOLoop.current`.
+ Deprecated since Tornado 4.1.
:arg max_buffer_size: Maximum amount of incoming data to buffer;
defaults to 100MB.
:arg read_chunk_size: Amount of data to read at one time from the
address of the other end of the connection). Note that this signature
is different from the ``callback(fd, events)`` signature used for
`.IOLoop` handlers.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
if io_loop is None:
io_loop = IOLoop.current()
The executor will be shut down when the resolver is closed unless
``close_resolver=False``; use this if you want to reuse the same
executor elsewhere.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def initialize(self, io_loop=None, executor=None, close_executor=True):
self.io_loop = io_loop or IOLoop.current()
so it is only recommended for use in ``AF_INET`` (i.e. IPv4). This is
the default for ``tornado.simple_httpclient``, but other libraries
may default to ``AF_UNSPEC``.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def initialize(self, io_loop=None):
self.io_loop = io_loop or IOLoop.current()
We override `mainLoop` instead of `doIteration` and must implement
timed call functionality on top of `IOLoop.add_timeout` rather than
using the implementation in `PosixReactorBase`.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def __init__(self, io_loop=None):
if not io_loop:
def install(io_loop=None):
- """Install this package as the default Twisted reactor."""
+ """Install this package as the default Twisted reactor.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
+ """
if not io_loop:
io_loop = tornado.ioloop.IOLoop.current()
reactor = TornadoReactor(io_loop)
``socket.AF_UNSPEC``.
Requires Twisted 12.1 or newer.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def initialize(self, io_loop=None):
self.io_loop = io_loop or IOLoop.current()
``tornado.process.Subprocess.STREAM``, which will make the corresponding
attribute of the resulting Subprocess a `.PipeIOStream`.
* A new keyword argument ``io_loop`` may be used to pass in an IOLoop.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
STREAM = object()
Note that the `.IOLoop` used for signal handling need not be the
same one used by individual Subprocess objects (as long as the
``IOLoops`` are each running in separate threads).
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
if cls._initialized:
return
class TCPClient(object):
"""A non-blocking TCP connection factory.
+
+ .. versionchanged:: 4.1
+ The ``io_loop`` argument is deprecated.
"""
def __init__(self, resolver=None, io_loop=None):
self.io_loop = io_loop or IOLoop.current()
Also accepts ``HTTPRequest`` objects in place of urls.
.. versionchanged:: 4.1
- Added ``compression_options``.
+ Added ``compression_options``. The ``io_loop`` argument is deprecated.
"""
if io_loop is None:
io_loop = IOLoop.current()