Api for tearing down components.

This commit is contained in:
Stephen Diehl
2012-02-26 23:52:20 -05:00
parent 6e8f1a7716
commit 651182869a
2 changed files with 18 additions and 2 deletions
+12 -2
View File
@@ -63,14 +63,20 @@ class Component(object):
def open(self):
raise NotImplementedError
def destroy(self):
def teardown_sockets(self):
"""
Tear down after normal operation.
Close all zmq sockets safely.
"""
#close all the sockets
for sock in self.sockets:
sock.close()
def destroy(self):
"""
Tear down after normal operation.
"""
pass
def kill(self):
"""
Tear down ( fast ) as a mode of failure in the
@@ -102,6 +108,10 @@ class Component(object):
self.loop()
self.destroy()
self.teardown_sockets()
# shouldn't block if we've done our job correctly
# self.context.term()
def run(self, catch_exceptions=False):
"""
+6
View File
@@ -130,12 +130,18 @@ class ComponentHost(Component):
# send synchronization reply
self.sync_socket.send('ack', self.zmq.NOBLOCK)
# ------------------
# Simulation Control
# ------------------
def launch_controller(self, controller):
raise NotImplementedError
def launch_component(self, component):
raise NotImplementedError
def teardown_component(self, component):
raise NotImplementedError
class ParallelBuffer(Component):
"""