diff --git a/zipline/component.py b/zipline/component.py index 7ab8bf5b..f7b42512 100644 --- a/zipline/component.py +++ b/zipline/component.py @@ -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): """ diff --git a/zipline/messaging.py b/zipline/messaging.py index a9d21bc3..222a1011 100644 --- a/zipline/messaging.py +++ b/zipline/messaging.py @@ -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): """