[zmq] Remove unused methods from executors
Change-Id: I2aa5f9a2ce51f3f0c5422d94eb28d2f37e3af458
This commit is contained in:
parent
885904e9ae
commit
f3ea04c568
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import threading
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
|
||||||
@ -67,23 +66,17 @@ class GreenExecutor(zmq_poller.Executor):
|
|||||||
def __init__(self, method):
|
def __init__(self, method):
|
||||||
self._method = method
|
self._method = method
|
||||||
super(GreenExecutor, self).__init__(None)
|
super(GreenExecutor, self).__init__(None)
|
||||||
self._done = threading.Event()
|
|
||||||
|
|
||||||
def _loop(self):
|
def _loop(self):
|
||||||
while not self._done.is_set():
|
while True:
|
||||||
self._method()
|
self._method()
|
||||||
eventlet.sleep()
|
eventlet.sleep()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.thread = eventlet.spawn(self._loop)
|
if self.thread is None:
|
||||||
|
self.thread = eventlet.spawn(self._loop)
|
||||||
def wait(self):
|
|
||||||
if self.thread is not None:
|
|
||||||
self.thread.wait()
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.thread is not None:
|
if self.thread is not None:
|
||||||
self.thread.kill()
|
self.thread.kill()
|
||||||
|
self.thread = None
|
||||||
def done(self):
|
|
||||||
self._done.set()
|
|
||||||
|
@ -72,8 +72,9 @@ class ThreadingExecutor(zmq_poller.Executor):
|
|||||||
|
|
||||||
def __init__(self, method):
|
def __init__(self, method):
|
||||||
self._method = method
|
self._method = method
|
||||||
super(ThreadingExecutor, self).__init__(
|
thread = threading.Thread(target=self._loop)
|
||||||
threading.Thread(target=self._loop))
|
thread.daemon = True
|
||||||
|
super(ThreadingExecutor, self).__init__(thread)
|
||||||
self._stop = threading.Event()
|
self._stop = threading.Event()
|
||||||
|
|
||||||
def _loop(self):
|
def _loop(self):
|
||||||
@ -81,14 +82,7 @@ class ThreadingExecutor(zmq_poller.Executor):
|
|||||||
self._method()
|
self._method()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.thread.daemon = True
|
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._stop.set()
|
self._stop.set()
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def done(self):
|
|
||||||
self._stop.set()
|
|
||||||
|
@ -100,11 +100,3 @@ class Executor(object):
|
|||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""Stop execution"""
|
"""Stop execution"""
|
||||||
|
|
||||||
@abc.abstractmethod
|
|
||||||
def wait(self):
|
|
||||||
"""Wait until pass"""
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
|
||||||
def done(self):
|
|
||||||
"""More soft way to stop rather than killing thread"""
|
|
||||||
|
Loading…
Reference in New Issue
Block a user