fix(conductor): add stop and wait methods to base
This prevents type checkers from failing when using the base Conductor class as a type. Closes-Bug: #2117198 Change-Id: I7633b100cc07f79637f1d9d553f3fcf323c57b4c Signed-off-by: Brett Delle Grazie <brett.dellegrazie@gmail.com>
This commit is contained in:
@@ -121,16 +121,12 @@ class ExecutorConductor(base.Conductor, metaclass=abc.ABCMeta):
|
||||
" it has not been")
|
||||
|
||||
def stop(self):
|
||||
"""Requests the conductor to stop dispatching.
|
||||
|
||||
This method can be used to request that a conductor stop its
|
||||
consumption & dispatching loop.
|
||||
|
||||
The method returns immediately regardless of whether the conductor has
|
||||
been stopped.
|
||||
"""
|
||||
self._wait_timeout.interrupt()
|
||||
|
||||
# Inherit the docs, so we can reference them in our class docstring,
|
||||
# if we don't do this sphinx gets confused...
|
||||
stop.__doc__ = base.Conductor.stop.__doc__
|
||||
|
||||
@property
|
||||
def dispatching(self):
|
||||
"""Whether or not the dispatching loop is still dispatching."""
|
||||
@@ -342,14 +338,8 @@ class ExecutorConductor(base.Conductor, metaclass=abc.ABCMeta):
|
||||
run.__doc__ = base.Conductor.run.__doc__
|
||||
|
||||
def wait(self, timeout=None):
|
||||
"""Waits for the conductor to gracefully exit.
|
||||
|
||||
This method waits for the conductor to gracefully exit. An optional
|
||||
timeout can be provided, which will cause the method to return
|
||||
within the specified timeout. If the timeout is reached, the returned
|
||||
value will be ``False``, otherwise it will be ``True``.
|
||||
|
||||
:param timeout: Maximum number of seconds that the :meth:`wait` method
|
||||
should block for.
|
||||
"""
|
||||
return self._dead.wait(timeout)
|
||||
|
||||
# Inherit the docs, so we can reference them in our class docstring,
|
||||
# if we don't do this sphinx gets confused...
|
||||
wait.__doc__ = base.Conductor.wait.__doc__
|
||||
|
||||
@@ -161,6 +161,30 @@ class Conductor(metaclass=abc.ABCMeta):
|
||||
forever and/or until stopped).
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def stop(self):
|
||||
"""Requests the conductor to stop dispatching.
|
||||
|
||||
This method can be used to request that a conductor stop its
|
||||
consumption & dispatching loop.
|
||||
|
||||
The method returns immediately regardless of whether the conductor has
|
||||
been stopped.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def wait(self, timeout=None):
|
||||
"""Waits for the conductor to gracefully exit.
|
||||
|
||||
This method waits for the conductor to gracefully exit. An optional
|
||||
timeout can be provided, which will cause the method to return
|
||||
within the specified timeout. If the timeout is reached, the returned
|
||||
value will be ``False``, otherwise it will be ``True``.
|
||||
|
||||
:param timeout: Maximum number of seconds that the :meth:`wait` method
|
||||
should block for.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def _dispatch_job(self, job):
|
||||
"""Dispatches a claimed job for work completion.
|
||||
|
||||
Reference in New Issue
Block a user