From b538dd67588ef39a9c5d56d03fa6f87dbe7d9861 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 3 Feb 2019 17:27:21 -0800 Subject: [PATCH] dilation.outbound: registerProducer goes on transport, not Protocol --- src/wormhole/_dilation/outbound.py | 10 +++++----- src/wormhole/test/dilate/test_outbound.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wormhole/_dilation/outbound.py b/src/wormhole/_dilation/outbound.py index 96fbd3d..96786ca 100644 --- a/src/wormhole/_dilation/outbound.py +++ b/src/wormhole/_dilation/outbound.py @@ -154,7 +154,7 @@ from .connection import KCM, Ping, Pong, Ack @attrs -@implementer(IOutbound) +@implementer(IOutbound, IPushProducer) class Outbound(object): # Manage outbound data: subchannel writes to us, we write to transport _manager = attrib(validator=provides(IDilationManager)) @@ -265,12 +265,12 @@ class Outbound(object): assert not self._queued_unsent self._queued_unsent.extend(self._outbound_queue) # the connection can tell us to pause when we send too much data - c.registerProducer(self, True) # IPushProducer: pause+resume + c.transport.registerProducer(self, True) # IPushProducer: pause+resume # send our queued messages self.resumeProducing() def stop_using_connection(self): - self._connection.unregisterProducer() + self._connection.transport.unregisterProducer() self._connection = None self._queued_unsent.clear() self.pauseProducing() @@ -290,8 +290,8 @@ class Outbound(object): # Inbound is responsible for tracking the high watermark and deciding # whether to ignore inbound messages or not - # IProducer: the active connection calls these because we used - # c.registerProducer to ask for them + # IPushProducer: the active connection calls these because we used + # c.transport.registerProducer to ask for them def pauseProducing(self): if self._paused: diff --git a/src/wormhole/test/dilate/test_outbound.py b/src/wormhole/test/dilate/test_outbound.py index 6ba5264..ed43a47 100644 --- a/src/wormhole/test/dilate/test_outbound.py +++ b/src/wormhole/test/dilate/test_outbound.py @@ -105,7 +105,7 @@ class OutboundTest(unittest.TestCase): # as soon as the connection is established, everything is sent o.use_connection(c) - self.assertEqual(c.mock_calls, [mock.call.registerProducer(o, True), + self.assertEqual(c.mock_calls, [mock.call.transport.registerProducer(o, True), mock.call.send_record(r1), mock.call.send_record(r2)]) self.assertEqual(list(o._outbound_queue), [r1, r2]) @@ -131,7 +131,7 @@ class OutboundTest(unittest.TestCase): # after each write. So only r1 should have been sent before getting # paused o.use_connection(c) - self.assertEqual(c.mock_calls, [mock.call.registerProducer(o, True), + self.assertEqual(c.mock_calls, [mock.call.transport.registerProducer(o, True), mock.call.send_record(r1)]) self.assertEqual(list(o._outbound_queue), [r1, r2]) self.assertEqual(list(o._queued_unsent), [r2]) @@ -172,7 +172,7 @@ class OutboundTest(unittest.TestCase): self.assertEqual(list(o._queued_unsent), []) o.use_connection(c) - self.assertEqual(c.mock_calls, [mock.call.registerProducer(o, True), + self.assertEqual(c.mock_calls, [mock.call.transport.registerProducer(o, True), mock.call.send_record(r1)]) self.assertEqual(list(o._outbound_queue), [r1, r2]) self.assertEqual(list(o._queued_unsent), [r2]) @@ -191,7 +191,7 @@ class OutboundTest(unittest.TestCase): def test_pause(self): o, m, c = make_outbound() o.use_connection(c) - self.assertEqual(c.mock_calls, [mock.call.registerProducer(o, True)]) + self.assertEqual(c.mock_calls, [mock.call.transport.registerProducer(o, True)]) self.assertEqual(list(o._outbound_queue), []) self.assertEqual(list(o._queued_unsent), []) clear_mock_calls(c) @@ -519,7 +519,7 @@ class OutboundTest(unittest.TestCase): o.use_connection(c) o.send_if_connected(KCM()) - self.assertEqual(c.mock_calls, [mock.call.registerProducer(o, True), + self.assertEqual(c.mock_calls, [mock.call.transport.registerProducer(o, True), mock.call.send_record(KCM())]) def test_tolerate_duplicate_pause_resume(self):