Internal method what runs container process

        :param name: str - name of container
        :param callback_method: list - how to invoke container
        :param foreground: bool run in background by default
        :return: suprocess instance
542724
def internal_run_container(name, callback_method, foreground=False):
        
        if not foreground:
            logger.info("Stating machine (boot nspawn container) {}".format(name))
            # wait until machine is booted when running at background, unable to execute commands without logind
            # in running container
            nspawn_process = NspawnContainer._internal_reschedule(callback_method)
            NspawnContainer._wait_for_machine_booted(name)
            logger.info("machine: %s starting finished" % name)
            return nspawn_process
        else:
            logger.info("Stating machine (return process) {}".format(name))
            return callback_method[0](callback_method[1], *callback_method[2], **callback_method[3])
1172734
function trackBackgroundProc() {
      runningProcs.push(proc);
      proc.on('close', function () {
        remove(runningProcs, proc);
        clearPid(name);
        grunt.log.debug('Process ' + name + ' closed.');
      });
    }
289294
def start_container(container)
      overlay_cidr = container.overlay_cidr

      if overlay_cidr
        wait_weave_running?
        register_container_dns(container) if container.service_container?
        attach_overlay(container)
      else
        debug "skip start for container=#{container.name} without overlay_cidr"
      end
    rescue Docker::Error::NotFoundError
      debug "skip start for missing container=#{container.id}"

    rescue => exc
      error "failed to start container: #{exc.class.name}: #{exc.message}"
      error exc.backtrace.join("\n")
    end
576445
def RunStateMethod(self, method_name, request=None, responses=None):
    
    if self._TerminationPending():
      return

    client_id = None
    try:
      self.context.current_state = method_name
      if request and responses:
        client_id = request.client_id or self.runner_args.client_id
        logging.debug("%s Running %s with %d responses from %s",
                      self.session_id, method_name, len(responses), client_id)

      else:
        logging.debug("%s Running state method %s", self.session_id,
                      method_name)

      # Extend our lease if needed.
      self.flow_obj.HeartBeat()
      try:
        method = getattr(self.flow_obj, method_name)
      except AttributeError:
        raise FlowRunnerError("Flow %s has no state method %s" %
                              (self.flow_obj.__class__.__name__, method_name))

      # Prepare a responses object for the state method to use:
      responses = flow_responses.Responses.FromLegacyResponses(
          request=request, responses=responses)

      self.SaveResourceUsage(responses.status)

      stats_collector_instance.Get().IncrementCounter("grr_worker_states_run")

      if method_name == "Start":
        stats_collector_instance.Get().IncrementCounter(
            "flow_starts", fields=[self.flow_obj.Name()])
        method()
      else:
        method(responses)

      if self.sent_replies:
        self.ProcessRepliesWithOutputPlugins(self.sent_replies)
        self.sent_replies = []

    # We don't know here what exceptions can be thrown in the flow but we have
    # to continue. Thus, we catch everything.
    except Exception as e:  # pylint: disable=broad-except
      # This flow will terminate now

      # TODO(user): Deprecate in favor of 'flow_errors'.
      stats_collector_instance.Get().IncrementCounter("grr_flow_errors")

      stats_collector_instance.Get().IncrementCounter(
          "flow_errors", fields=[self.flow_obj.Name()])
      logging.exception("Flow %s raised %s.", self.session_id, e)

      self.Error(traceback.format_exc(), client_id=client_id)
1313290
public synchronized void checkProcessHasStopped(String processName) {
        NamedProcess p = processes.get(processName);
        if ( p == null ) {
            throw new ChorusException("There is no process named '" + processName + "' to check is stopped");
        }
        ChorusAssert.assertTrue("The process " + processName + " was not stopped", p.getProcess().isStopped());
    }
1272813
def interact(self, container: Container) -> None:
        
        cmd = "/bin/bash -c 'source /.environment && /bin/bash'"
        cmd = "docker exec -it {} {}".format(container.id, cmd)
        subprocess.call(cmd, shell=True)
1225138
def _run_container(self, run_command_instance, callback):
        
        tmpfile = os.path.join(get_backend_tmpdir(), random_tmp_filename())
        # the cid file must not exist
        run_command_instance.options += ["--cidfile=%s" % tmpfile]
        logger.debug("docker command: %s" % run_command_instance)
        response = callback()

        def get_cont_id():
            if not os.path.exists(tmpfile):
                return False
            with open(tmpfile, 'r') as fd:
                content = fd.read()
            return bool(content)

        Probe(timeout=2, count=10, pause=0.1, fnc=get_cont_id).run()

        with open(tmpfile, 'r') as fd:
            container_id = fd.read()

        if not container_id:
            raise ConuException("We could not get container's ID, it probably was not created")
        return container_id, response
371167
public void doBackgroundOp( final Runnable run, final boolean showWaitCursor )
  {
    final Component[] key = new Component[1];
    ExecutorService jobRunner = getJobRunner();
    if( jobRunner != null )
    {
      jobRunner.submit( () -> performBackgroundOp( run, key, showWaitCursor ) );
    }
    else
    {
      run.run();
    }
  }
55140
def is_running(config, container, *args, **kwargs):
    '''
    
    '''
    try:
        infos = _get_container_infos(config, container)
        return (infos if infos.get('State', {}).get('Running') else None)
    except Exception:
        return None
941095
def container_running(self, id=None, name=None):
        
        running = False
        if id:
            running = self.inspect_container(id)['State']['Running']
        elif name:
            running = self.inspect_container(name)['State']['Running']
        return running
822905
def process_event(self, module_name, event, default_event=False):
        

        # get the module that the event is for
        module_info = self.output_modules.get(module_name)

        # if module is a py3status one call it.
        if module_info["type"] == "py3status":
            module = module_info["module"]
            module.click_event(event)
            if self.config["debug"]:
                self.py3_wrapper.log("dispatching event {}".format(event))

            # to make the bar more responsive to users we refresh the module
            # unless the on_click event called py3.prevent_refresh()
            if not module.prevent_refresh:
                self.py3_wrapper.refresh_modules(module_name)
                default_event = False

        if default_event:
            # default button 2 action is to clear this method's cache
            if self.config["debug"]:
                self.py3_wrapper.log("dispatching default event {}".format(event))
            self.py3_wrapper.refresh_modules(module_name)

        # find container that holds the module and call its onclick
        module_groups = self.py3_config[".module_groups"]
        containers = module_groups.get(module_name, [])
        for container in containers:
            self.process_event(container, event)
1366245
private synchronized ChorusProcess getAndCheckProcessByName(String processName) {
        NamedProcess p = processes.get(processName);
        if ( p == null ) {
            ChorusAssert.fail("Could not find the process " + processName);
        }
        return p.getProcess();
    }
789284
def run_callback(method, *args)
      case method
      when Symbol
        send(method, *args)
      when Proc
        instance_exec(*args, &method)
      else
        raise "Please register with callbacks using a symbol or a block/proc."
      end
    end
341307
def notify(name, states, callback):
    '''
    
    '''
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)

    cmd = ['lxc-wait', '-n', name, '-s', states]
    def th():
        subprocess.check_call(cmd)
        callback()
    _logger.info("Waiting on states %s for container %s", states, name)
    threading.Thread(target=th).start()
661418
async def run(self, config, *, name=None):
        
        try:
            container = await self.create(config, name=name)
        except DockerError as err:
            # image not find, try pull it
            if err.status == 404 and "Image" in config:
                await self.docker.pull(config["Image"])
                container = await self.create(config, name=name)
            else:
                raise err

        try:
            await container.start()
        except DockerError as err:
            raise DockerContainerError(
                err.status, {"message": err.message}, container["id"]
            )

        return container
605022
def container_by_name(self, name):
        
        if not name:
            return None

        # docker prepends a '/' to container names in the container dict
        name = '/'+name
        return next((container for container in self.containers(all=True)
                     if name in container['Names']), None)
867691
def invoke(name, args=ARGV)
      logger.debug "invoke name: #{name}, args #{args.inspect}, configuration defined: #{configuration ? 'yes' : 'no'}"
      args = args.dup
      load_tasks

      logger.debug "find_by_namespace: #{name}"
      klass, task  = find_by_namespace(name)

      if klass
        config = {}
        config[:shell] ||= shell
        klass.send(:dispatch, task, args, nil, config) do |instance|
          if defined?(instance.configuration)
            instance.configuration = configuration.deep_clone
          end
        end
        logger.debug "after invoke"
        result = 0
      else
        puts "Could not find task #{name}"
        result = 1
      end
      result
    end