[zmq] Remove unused methods from executors

Change-Id: I2aa5f9a2ce51f3f0c5422d94eb28d2f37e3af458
This commit is contained in:
Gevorg Davoian 2016-09-22 19:14:15 +03:00
parent 885904e9ae
commit f3ea04c568
3 changed files with 7 additions and 28 deletions

View File

@ -13,7 +13,6 @@
# under the License.
import logging
import threading
import eventlet
@ -67,23 +66,17 @@ class GreenExecutor(zmq_poller.Executor):
def __init__(self, method):
self._method = method
super(GreenExecutor, self).__init__(None)
self._done = threading.Event()
def _loop(self):
while not self._done.is_set():
while True:
self._method()
eventlet.sleep()
def execute(self):
self.thread = eventlet.spawn(self._loop)
def wait(self):
if self.thread is not None:
self.thread.wait()
if self.thread is None:
self.thread = eventlet.spawn(self._loop)
def stop(self):
if self.thread is not None:
self.thread.kill()
def done(self):
self._done.set()
self.thread = None

View File

@ -72,8 +72,9 @@ class ThreadingExecutor(zmq_poller.Executor):
def __init__(self, method):
self._method = method
super(ThreadingExecutor, self).__init__(
threading.Thread(target=self._loop))
thread = threading.Thread(target=self._loop)
thread.daemon = True
super(ThreadingExecutor, self).__init__(thread)
self._stop = threading.Event()
def _loop(self):
@ -81,14 +82,7 @@ class ThreadingExecutor(zmq_poller.Executor):
self._method()
def execute(self):
self.thread.daemon = True
self.thread.start()
def stop(self):
self._stop.set()
def wait(self):
pass
def done(self):
self._stop.set()

View File

@ -100,11 +100,3 @@ class Executor(object):
@abc.abstractmethod
def stop(self):
"""Stop execution"""
@abc.abstractmethod
def wait(self):
"""Wait until pass"""
@abc.abstractmethod
def done(self):
"""More soft way to stop rather than killing thread"""