code: def populate(self, installed_bots=None):
          if self.ready:
              return
          with self._lock:
              if self.ready:
                  return
              if self.loading:
                  raise RuntimeError("populate() isn't re-entrant")
              self.loading = True
              for entry in installed_bots or {}:
                  if isinstance(entry, Bot):
                      cls = entry
                      entry = '.'.join([cls.__module__, cls.__name__])
                  bot_reg = BotRegistry.create(entry)
                  if bot_reg.label in self.bots:
                      raise ImproperlyConfigured(
                          "Bot labels aren't unique, "
                          "duplicates: %s" % bot_reg.label)
                  self.bots[bot_reg.label] = bot_reg
                  bot_reg.bots = self
              counts = Counter(
                  bot_reg.name for bot_reg in self.bots.values())
              duplicates = [
                  name for name, count in counts.most_common() if count > 1]
              if duplicates:
                  raise ImproperlyConfigured(
                      "Bot names aren't unique, "
                      "duplicates: %s" % ", ".join(duplicates))
              self.bots_ready = True
              for bot in self.bots.values():
                  bot.import_configs()
              self.configs_ready = True
              self.ready = True