Public Member Functions | |
def | add_callback |
def | add_callback_from_signal |
def | add_handler |
def | add_timeout |
def | close |
def | initialize |
def | remove_handler |
def | remove_timeout |
def | start |
def | stop |
def | update_handler |
Public Attributes | |
fds | |
reactor |
IOLoop implementation that runs on Twisted. Uses the global Twisted reactor by default. To create multiple `TwistedIOLoops` in the same process, you must pass a unique reactor when constructing each one. Not compatible with `tornado.process.Subprocess.set_exit_callback` because the ``SIGCHLD`` handlers used by Tornado and Twisted conflict with each other.
Definition at line 398 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.add_callback | ( | self, | |
callback, | |||
args, | |||
kwargs | |||
) |
Calls the given callback on the next I/O loop iteration. It is safe to call this method from any thread at any time, except from a signal handler. Note that this is the **only** method in `IOLoop` that makes this thread-safety guarantee; all other interaction with the `IOLoop` must be done from that `IOLoop`'s thread. `add_callback()` may be used to transfer control from other threads to the `IOLoop`'s thread. To add a callback from a signal handler, see `add_callback_from_signal`.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 493 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.add_callback_from_signal | ( | self, | |
callback, | |||
args, | |||
kwargs | |||
) |
Calls the given callback on the next I/O loop iteration. Safe for use from a Python signal handler; should not be used otherwise. Callbacks added with this method will be run without any `.stack_context`, to avoid picking up the context of the function that was interrupted by the signal.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 498 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.add_handler | ( | self, | |
fd, | |||
handler, | |||
events | |||
) |
Registers the given handler to receive the given events for ``fd``. The ``fd`` argument may either be an integer file descriptor or a file-like object with a ``fileno()`` method (and optionally a ``close()`` method, which may be called when the `IOLoop` is shut down). The ``events`` argument is a bitwise or of the constants ``IOLoop.READ``, ``IOLoop.WRITE``, and ``IOLoop.ERROR``. When an event occurs, ``handler(fd, events)`` will be run. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 426 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.add_timeout | ( | self, | |
deadline, | |||
callback, | |||
args, | |||
kwargs | |||
) |
Runs the ``callback`` at the time ``deadline`` from the I/O loop. Returns an opaque handle that may be passed to `remove_timeout` to cancel. ``deadline`` may be a number denoting a time (on the same scale as `IOLoop.time`, normally `time.time`), or a `datetime.timedelta` object for a deadline relative to the current time. Since Tornado 4.0, `call_later` is a more convenient alternative for the relative case since it does not require a timedelta object. Note that it is not safe to call `add_timeout` from other threads. Instead, you must use `add_callback` to transfer control to the `IOLoop`'s thread, and then call `add_timeout` from there. Subclasses of IOLoop must implement either `add_timeout` or `call_at`; the default implementations of each will call the other. `call_at` is usually easier to implement, but subclasses that wish to maintain compatibility with Tornado versions prior to 4.0 must use `add_timeout` instead. .. versionchanged:: 4.0 Now passes through ``*args`` and ``**kwargs`` to the callback.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 475 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.close | ( | self, | |
all_fds = False |
|||
) |
Closes the `IOLoop`, freeing any resources used. If ``all_fds`` is true, all file descriptors registered on the IOLoop will be closed (not just the ones created by the `IOLoop` itself). Many applications will only use a single `IOLoop` that runs for the entire lifetime of the process. In that case closing the `IOLoop` is not necessary since everything will be cleaned up when the process exits. `IOLoop.close` is provided mainly for scenarios such as unit tests, which create and destroy a large number of ``IOLoops``. An `IOLoop` must be completely stopped before it can be closed. This means that `IOLoop.stop()` must be called *and* `IOLoop.start()` must be allowed to return before attempting to call `IOLoop.close()`. Therefore the call to `close` will usually appear just after the call to `start` rather than near the call to `stop`. .. versionchanged:: 3.1 If the `IOLoop` implementation supports non-integer objects for "file descriptors", those objects will have their ``close`` method when ``all_fds`` is true.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 417 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.initialize | ( | self, | |
reactor = None |
|||
) |
Definition at line 409 of file twisted.py.
Stop listening for events on ``fd``. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 457 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.remove_timeout | ( | self, | |
timeout | |||
) |
Cancels a pending timeout. The argument is a handle as returned by `add_timeout`. It is safe to call `remove_timeout` even if the callback has already been run.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 489 of file twisted.py.
Starts the I/O loop. The loop will run until one of the callbacks calls `stop()`, which will make the loop stop after the current event iteration completes.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 468 of file twisted.py.
Stop the I/O loop. If the event loop is not currently running, the next call to `start()` will return immediately. To use asynchronous methods from otherwise-synchronous code (such as unit tests), you can start and stop the event loop like this:: ioloop = IOLoop() async_method(ioloop=ioloop, callback=ioloop.stop) ioloop.start() ``ioloop.start()`` will return after ``async_method`` has run its callback, whether that callback was invoked before or after ``ioloop.start``. Note that even after `stop` has been called, the `IOLoop` is not completely stopped until `IOLoop.start` has also returned. Some work that was scheduled before the call to `stop` may still be run before the `IOLoop` shuts down.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 472 of file twisted.py.
def rosbridge_tools.tornado.platform.twisted.TwistedIOLoop.update_handler | ( | self, | |
fd, | |||
events | |||
) |
Changes the events we listen for ``fd``. .. versionchanged:: 4.0 Added the ability to pass file-like objects in addition to raw file descriptors.
Reimplemented from rosbridge_tools.tornado.ioloop.IOLoop.
Definition at line 438 of file twisted.py.
Definition at line 409 of file twisted.py.
Definition at line 409 of file twisted.py.