diff --git a/zipline/component.py b/zipline/component.py index 8c6621d9..6fda03c4 100644 --- a/zipline/component.py +++ b/zipline/component.py @@ -139,7 +139,7 @@ class Component(object): # systems where this becomes needed. Add this option. # # http://zeromq.github.com/pyzmq/morethanbindings.html#thread-safety - self.context = self.zmq.Context() + self.context = self.zmq.Context.instance() self.setup_poller() @@ -179,8 +179,6 @@ class Component(object): self.shutdown() self.teardown_sockets() - if self.context: - self.context.destroy() if fail: raise fail else: diff --git a/zipline/monitor.py b/zipline/monitor.py index 7f6cab2d..5db2ea54 100644 --- a/zipline/monitor.py +++ b/zipline/monitor.py @@ -76,7 +76,7 @@ class Controller(object): self.polling = True if not context: - self._ctx = zmq.Context() + self._ctx = zmq.Context.instance() else: self._ctx = context @@ -142,7 +142,7 @@ class Controller(object): """ if not context: - context = zmq.Context() + context = zmq.Context.instance() s = context.socket(zmq.PUSH) s.connect(self.push_socket) @@ -156,7 +156,7 @@ class Controller(object): """ if not context: - context = zmq.Context() + context = zmq.Context.instance() s = context.socket(zmq.SUB) s.connect(self.sub_socket) @@ -168,7 +168,7 @@ class Controller(object): self.polling = False if not context: - context = zmq.Context() + context = zmq.Context.instance() #logging.info('Shutdown controller')