Merge "Fix inconsistent interface of ThreadGroup"
This commit is contained in:
@@ -22,8 +22,6 @@ from oslo_service.backend.threading import loopingcall
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
# --- New: Add a Thread wrapper to mimic the eventlet interface ---
|
|
||||||
|
|
||||||
|
|
||||||
class Thread:
|
class Thread:
|
||||||
"""A simple wrapper around native threads.
|
"""A simple wrapper around native threads.
|
||||||
@@ -63,8 +61,6 @@ class Thread:
|
|||||||
# Optionally implement cancellation if required.
|
# Optionally implement cancellation if required.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# --- End of new Thread wrapper ---
|
|
||||||
|
|
||||||
|
|
||||||
class ThreadGroup:
|
class ThreadGroup:
|
||||||
"""A group of threads and timers similar to eventlet's GreenPool."""
|
"""A group of threads and timers similar to eventlet's GreenPool."""
|
||||||
@@ -215,6 +211,9 @@ class ThreadGroup:
|
|||||||
self.threads = [t for t in self.threads if t is current]
|
self.threads = [t for t in self.threads if t is current]
|
||||||
|
|
||||||
def waitall(self):
|
def waitall(self):
|
||||||
|
"""Block until all timers and threads in the group are complete.
|
||||||
|
|
||||||
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
threads_copy = list(self.threads)
|
threads_copy = list(self.threads)
|
||||||
timers_copy = list(self.timers)
|
timers_copy = list(self.timers)
|
||||||
@@ -225,6 +224,9 @@ class ThreadGroup:
|
|||||||
for timer in timers_copy:
|
for timer in timers_copy:
|
||||||
timer.wait()
|
timer.wait()
|
||||||
|
|
||||||
|
# NOTE(tkajinam): To keep interface consistent with eventlet version
|
||||||
|
wait = waitall
|
||||||
|
|
||||||
def _set_attr(self, obj, attr, value):
|
def _set_attr(self, obj, attr, value):
|
||||||
try:
|
try:
|
||||||
object.__setattr__(obj, attr, value)
|
object.__setattr__(obj, attr, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user