'Return the next available channel number or raise an exception.
:rtype: int'

def _next_channel_number(self):

    limit = (self.params.channel_max or pika.channel.MAX_CHANNELS)
    if (len(self._channels) >= limit):
        raise exceptions.NoFreeChannels()
    for num in xrange(1, (len(self._channels) + 1)):
        if (num not in self._channels):
            return num
    return (len(self._channels) + 1)
