Skip to content

Commit

Permalink
Changed _get_next_available_channel_id to loop through and find first…
Browse files Browse the repository at this point in the history
… available
  • Loading branch information
mikemrm committed May 17, 2018
1 parent 2128e62 commit 3530608
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions amqpstorm/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,12 @@ def _get_next_available_channel_id(self):
:rtype: int
"""
num_channels = len(self._channels) + 1
if num_channels == self.max_allowed_channels:
raise AMQPConnectionError(
'reached the maximum number of channels %d' %
self.max_allowed_channels)

if num_channels <= self.max_allowed_channels:
return num_channels

for index in compatibility.RANGE(1, num_channels):
for index in compatibility.RANGE(1, self.max_allowed_channels):
if index in self._channels:
continue
return index
raise AMQPConnectionError('reached the maximum number of channels %d' %
self.max_allowed_channels)

def _handle_amqp_frame(self, data_in):
"""Unmarshal a single AMQP frame and return the result.
Expand Down

0 comments on commit 3530608

Please sign in to comment.