Executor docstring & attribute tweaks
Adjust some docstrings to better align with the class they are attached to. Also changes some docstrings for the pooled executor (as it is an abstraction on-top of async executors, and is not tied to threads anymore) and correctly denote this on its attributes that others can and are overriding. Change-Id: I2eaaeed3aa0ae64eb5c82843381b7518ac508ac1
This commit is contained in:
parent
9eef14f1c0
commit
c5389bebce
@ -35,7 +35,6 @@ class FakeBlockingThread(object):
|
|||||||
|
|
||||||
|
|
||||||
class BlockingExecutor(impl_pooledexecutor.PooledExecutor):
|
class BlockingExecutor(impl_pooledexecutor.PooledExecutor):
|
||||||
|
|
||||||
"""A message executor which blocks the current thread.
|
"""A message executor which blocks the current thread.
|
||||||
|
|
||||||
The blocking executor's start() method functions as a request processing
|
The blocking executor's start() method functions as a request processing
|
||||||
|
@ -25,7 +25,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class EventletExecutor(impl_pooledexecutor.PooledExecutor):
|
class EventletExecutor(impl_pooledexecutor.PooledExecutor):
|
||||||
|
|
||||||
"""A message executor which integrates with eventlet.
|
"""A message executor which integrates with eventlet.
|
||||||
|
|
||||||
This is an executor which polls for incoming messages from a greenthread
|
This is an executor which polls for incoming messages from a greenthread
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import functools
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
@ -31,25 +32,30 @@ _pool_opts = [
|
|||||||
|
|
||||||
|
|
||||||
class PooledExecutor(base.ExecutorBase):
|
class PooledExecutor(base.ExecutorBase):
|
||||||
"""A message executor which integrates with threads.
|
"""A message executor which integrates with some async executor.
|
||||||
|
|
||||||
A message process that polls for messages from a dispatching thread and
|
This will create a message thread that polls for messages from a
|
||||||
on reception of an incoming message places the message to be processed in
|
dispatching thread and on reception of an incoming message places the
|
||||||
a thread pool to be executed at a later time.
|
message to be processed into a async executor to be executed at a later
|
||||||
|
time.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# NOTE(harlowja): if eventlet is being used and the thread module is monkey
|
# These may be overridden by subclasses (and implemented using whatever
|
||||||
# patched this should/is supposed to work the same as the eventlet based
|
# objects make most sense for the provided async execution model).
|
||||||
# executor.
|
|
||||||
|
|
||||||
# NOTE(harlowja): Make it somewhat easy to change this via
|
|
||||||
# inheritance (since there does exist other executor types that could be
|
|
||||||
# used/tried here).
|
|
||||||
_executor_cls = futures.ThreadPoolExecutor
|
|
||||||
_event_cls = threading.Event
|
_event_cls = threading.Event
|
||||||
_lock_cls = threading.Lock
|
_lock_cls = threading.Lock
|
||||||
|
|
||||||
|
# Pooling and dispatching (executor submission) will happen from a
|
||||||
|
# thread created from this class/function.
|
||||||
_thread_cls = threading.Thread
|
_thread_cls = threading.Thread
|
||||||
|
|
||||||
|
# This one **must** be overridden by a subclass.
|
||||||
|
_executor_cls = None
|
||||||
|
|
||||||
|
# Blocking function that should wait for all provided futures to finish.
|
||||||
|
_wait_for_all = functools.partial(futures.wait,
|
||||||
|
return_when=futures.ALL_COMPLETED)
|
||||||
|
|
||||||
def __init__(self, conf, listener, dispatcher):
|
def __init__(self, conf, listener, dispatcher):
|
||||||
super(PooledExecutor, self).__init__(conf, listener, dispatcher)
|
super(PooledExecutor, self).__init__(conf, listener, dispatcher)
|
||||||
self.conf.register_opts(_pool_opts)
|
self.conf.register_opts(_pool_opts)
|
||||||
@ -108,5 +114,5 @@ class PooledExecutor(base.ExecutorBase):
|
|||||||
incomplete_fs = list(self._incomplete)
|
incomplete_fs = list(self._incomplete)
|
||||||
self._incomplete.clear()
|
self._incomplete.clear()
|
||||||
if incomplete_fs:
|
if incomplete_fs:
|
||||||
futures.wait(incomplete_fs, return_when=futures.ALL_COMPLETED)
|
self._wait_for_all(incomplete_fs)
|
||||||
self._executor = None
|
self._executor = None
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from concurrent import futures
|
import futurist
|
||||||
|
|
||||||
from oslo_messaging._executors import impl_pooledexecutor
|
from oslo_messaging._executors import impl_pooledexecutor
|
||||||
|
|
||||||
@ -26,4 +26,5 @@ class ThreadExecutor(impl_pooledexecutor.PooledExecutor):
|
|||||||
on reception of an incoming message places the message to be processed in
|
on reception of an incoming message places the message to be processed in
|
||||||
a thread pool to be executed at a later time.
|
a thread pool to be executed at a later time.
|
||||||
"""
|
"""
|
||||||
_executor_cls = futures.ThreadPoolExecutor
|
|
||||||
|
_executor_cls = futurist.ThreadPoolExecutor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user