Skip to content

Commit

Permalink
Merge pull request #1276 from Zephor5/keep_with_origin_bh
Browse files Browse the repository at this point in the history
ready return TwistedProtocolConnection instance as before
  • Loading branch information
lukebakken committed Jan 27, 2021
2 parents 46fa486 + eab4ba1 commit 1e4efb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pika/adapters/twisted_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,11 @@ def channel(self, channel_number=None): # pylint: disable=W0221
d.addCallback(self._clear_call, d)
return d.addCallback(TwistedChannel)

@property
def is_open(self):
# For compatibility with previous releases.
return self._impl.is_open

@property
def is_closed(self):
# For compatibility with previous releases.
Expand Down Expand Up @@ -1232,6 +1237,7 @@ def makeConnection(self, transport):
def connectionReady(self):
"""This method will be called when the underlying connection is ready.
"""
return self

def _on_connection_ready(self, _connection):
d, self.ready = self.ready, None
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/twisted_adapter_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# pylint: disable=E1101

"""twisted adapter test"""
import functools
import unittest

import mock
Expand Down Expand Up @@ -707,7 +708,7 @@ def test_on_connection_ready(self):
d = self.conn.ready
self.conn._on_connection_ready("testresult")
self.assertTrue(d.called)
d.addCallback(self.assertIsNone)
d.addCallback(functools.partial(self.assertIsInstance, cls=TwistedProtocolConnection))
return d

def test_on_connection_ready_twice(self):
Expand Down

0 comments on commit 1e4efb4

Please sign in to comment.