mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-10 11:50:32 +08:00
Api for tearing down components.
This commit is contained in:
+12
-2
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user