Class LoopRunner
A helper to start and stop an IO loop in a controlled way. Several loop runners can associate safely to the same IO loop.
Declaration
class LoopRunner
source linkDocumentation
Attributes
- loop : IOLoop
If given, this loop will be re-used, otherwise an appropriate one
will be looked up or created.
- asynchronous : boolean (optional, default False)
If false (the default), the loop is meant to run in a separate
thread and will be started if necessary.
If true, the loop is meant to run in the thread this
object is instantiated from, and will not be started automatically.
Methods
▷ def __init__(self, loop=None, asynchronous=False) ▷ def is_started(self) Return True between start() and stop() calls, False otherwise.
▷ def loop(self) @property ▷ def run_sync(self, func, *args, **kwargs) Convenience helper: start the loop if needed, run sync(func, *args, **kwargs), then stop the loop again.
▶ def start(self) Start the IO loop if required. The loop is run in a dedicated thread.
If the loop is already running, this method does nothing.
▷ def stop(self, timeout=10) Stop and close the loop if it was created by us. Otherwise, just mark this object "stopped".
Reexports