def _handleRequire(self, container, wait_time):
    env = []
    # Wait for any required services to finish registering        
    config = self.config['containers'][container]
    if 'require' in config:
      try:
        # Containers can depend on mulitple services
        for service in config['require']:
          service_env = []
          port = config['require'][service]['port']          
          if port:
            # If count is defined then we need to wait for all instances to start                    
            count = config['require'][service].get('count', 1)          
            if count > 1:
              while count > 0:
                name = service + "__" + str(count)
                service_env.append(self._pollService(container, name, port, wait_time))
                count = count - 1                
            else:
              service_env.append(self._pollService(container, service, port, wait_time))

            env.append(service.upper() + "=" + " ".join(service_env))
      except:
        self.log.error('Failure on require. Shutting down the environment')
        self.destroy()
        raise
      
      # Setup the env for dependent services
      if 'environment' in config['config']:
        config['config']['environment'] += env
      else:
        config['config']['environment'] = env
dataset/ETHPy150Open kstaken/dockermix/dockermix/dockermix.py/ContainerMix._handleRequire/original