diff --git a/amqp/connection.py b/amqp/connection.py index 3e9097fd..1dd52c1a 100644 --- a/amqp/connection.py +++ b/amqp/connection.py @@ -484,6 +484,7 @@ def collect(self): def _get_free_channel_id(self): for channel_id in range(1, self.channel_max): if channel_id not in self._used_channel_ids: + self._used_channel_ids.append(channel_id) return channel_id raise ResourceError( diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py index 03f02585..dfa9a745 100644 --- a/t/unit/test_connection.py +++ b/t/unit/test_connection.py @@ -350,6 +350,7 @@ def test_collect_again(self): def test_get_free_channel_id(self): assert self.conn._get_free_channel_id() == 1 + assert self.conn._get_free_channel_id() == 2 def test_get_free_channel_id__raises_IndexError(self): self.conn._used_channel_ids = array('H', range(1, self.conn.channel_max))