From 31e0e8208cc026653f979c0599de148cd2495868 Mon Sep 17 00:00:00 2001 From: fawce Date: Tue, 3 Jul 2012 11:37:58 -0400 Subject: [PATCH] switching to use push/pull for traffic btw merge and client --- tests/test_finance.py | 1 - zipline/components/tradesimulation.py | 1 + zipline/core/component.py | 21 +++++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/test_finance.py b/tests/test_finance.py index 52807b6d..c208b2c5 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -210,7 +210,6 @@ class FinanceTestCase(TestCase): "The merge should be drained of all messages, found {n} remaining." \ .format(n=zipline.sim.merge.pending_messages()) ) - self.assertEqual( zipline.algorithm.count, zipline.algorithm.incr, diff --git a/zipline/components/tradesimulation.py b/zipline/components/tradesimulation.py index f130be0b..fa667a67 100644 --- a/zipline/components/tradesimulation.py +++ b/zipline/components/tradesimulation.py @@ -49,6 +49,7 @@ class TradeSimulationClient(Component): self.perf.open(self.context) def do_work(self): + from rdb import set_trace; set_trace() # poll all the sockets socks = dict(self.poll.poll(self.heartbeat_timeout)) diff --git a/zipline/core/component.py b/zipline/core/component.py index 3778ac5c..030c16e2 100644 --- a/zipline/core/component.py +++ b/zipline/core/component.py @@ -486,10 +486,27 @@ class Component(object): return self.connect_push_socket(self.addresses['merge_address']) def bind_result(self): - return self.bind_pub_socket(self.addresses['result_address']) + return self.bind_push_socket(self.addresses['result_address']) def connect_result(self): - return self.connect_sub_socket(self.addresses['result_address']) + return self.connect_pull_socket(self.addresses['result_address']) + + def bind_push_socket(self, addr): + push_socket = self.context.socket(self.zmq.PUSH) + push_socket.bind(addr) + self.out_socket = push_socket + self.sockets.append(push_socket) + + return push_socket + + def connect_pull_socket(self, addr): + pull_socket = self.context.socket(self.zmq.PULL) + pull_socket.connect(addr) + self.sockets.append(pull_socket) + self.poll.register(pull_socket, self.zmq.POLLIN) + + return pull_socket + def bind_pull_socket(self, addr): pull_socket = self.context.socket(self.zmq.PULL)