code: def allocate_resource_id(self):
          
  
          self.resource_id_lock.acquire()
          try:
              i = self.last_resource_id
              while i in self.resource_ids:
                  i = i + 1
                  if i > self.info.resource_id_mask:
                      i = 0
                  if i == self.last_resource_id:
                      raise error.ResourceIDError('out of resource ids')
  
              self.resource_ids[i] = None
              self.last_resource_id = i
              return self.info.resource_id_base | i
          finally:
              self.resource_id_lock.release()
docs: id = d.allocate_resource_id()
  
          Allocate a new X resource id number ID.
  
          Raises ResourceIDError if there are no free resource ids.