code: def _next_channel(self):
          
          chanid = self._channel_counter
          while self._channels.get(chanid) is not None:
              self._channel_counter = (self._channel_counter + 1) & 0xffffff
              chanid = self._channel_counter
          self._channel_counter = (self._channel_counter + 1) & 0xffffff
          return chanid
docs: you are holding the lock