Skip to content

Commit

Permalink
Merge pull request #1210 from keith-bennett-gbg/keithb/blocking-chann…
Browse files Browse the repository at this point in the history
…el-consumer-tags

add consumer_tags property to BlockingChannel
  • Loading branch information
lukebakken committed May 2, 2019
2 parents eb8d113 + 20a97af commit 9201ab8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pika/adapters/blocking_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,16 @@ def is_open(self):
"""
return self._impl.is_open

@property
def consumer_tags(self):
"""Property method that returns a list of consumer tags for active
consumers
:rtype: list
"""
return compat.dictkeys(self._consumer_infos)

_ALWAYS_READY_WAITERS = ((lambda: True),)

def _flush_output(self, *waiters):
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/blocking_channel_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,12 @@ def test_context_manager_exit_with_closed_channel(self):
chan.close()
chan._impl.close.assert_called_with(
reply_code=0, reply_text='Normal shutdown')

def test_consumer_tags_property(self):
with mock.patch.object(self.obj._impl, '_generate_consumer_tag'):
self.assertEqual(0, len(self.obj.consumer_tags))
self.obj._impl._generate_consumer_tag.return_value = 'ctag0'
self.obj._impl.basic_consume.return_value = 'ctag0'
self.obj.basic_consume('queue', mock.Mock())
self.assertEqual(1, len(self.obj.consumer_tags))
self.assertIn('ctag0', self.obj.consumer_tags)

0 comments on commit 9201ab8

Please sign in to comment.