Start executor process via running an async shell process
9418
@VisibleForTesting
  protected Process startExecutorProcess(int container, Set<PackingPlan.InstancePlan> instances) {
    return ShellUtils.runASyncProcess(
        getExecutorCommand(container, instances),
        new File(LocalContext.workingDirectory(config)),
        Integer.toString(container));
  }
105448
def run(self, asynchronous=False):
        '''
        
        '''
        log.debug('Process Manager starting!')
        appendproctitle(self.name)

        # make sure to kill the subprocesses if the parent is killed
        if signal.getsignal(signal.SIGTERM) is signal.SIG_DFL:
            # There are no SIGTERM handlers installed, install ours
            signal.signal(signal.SIGTERM, self.kill_children)
        if signal.getsignal(signal.SIGINT) is signal.SIG_DFL:
            # There are no SIGINT handlers installed, install ours
            signal.signal(signal.SIGINT, self.kill_children)

        while True:
            log.trace('Process manager iteration')
            try:
                # in case someone died while we were waiting...
                self.check_children()
                # The event-based subprocesses management code was removed from here
                # because os.wait() conflicts with the subprocesses management logic
                # implemented in `multiprocessing` package. See #35480 for details.
                if asynchronous:
                    yield gen.sleep(10)
                else:
                    time.sleep(10)
                if not self._process_map:
                    break
            # OSError is raised if a signal handler is called (SIGTERM) during os.wait
            except OSError:
                break
            except IOError as exc:
                # IOError with errno of EINTR (4) may be raised
                # when using time.sleep() on Windows.
                if exc.errno != errno.EINTR:
                    raise
                break
109288
function run(exec, args, shell, callback) {
    var env = extend({}, this.env)
    env.TERM = 'dumb'
    const opts = { env: env, shell: shell }

    this.log.silly('execFile: exec = %j', exec)
    this.log.silly('execFile: args = %j', args)
    this.log.silly('execFile: opts = %j', opts)
    try {
      this.execFile(exec, args, opts, execFileCallback.bind(this))
    } catch (err) {
      this.log.silly('execFile: threw:\n%s', err.stack)
      return callback(err)
    }

    function execFileCallback(err, stdout, stderr) {
      this.log.silly('execFile result: err = %j', err && err.stack || err)
      this.log.silly('execFile result: stdout = %j', stdout)
      this.log.silly('execFile result: stderr = %j', stderr)
      if (err) {
        return callback(err)
      }
      const execPath = stdout.trim()
      callback(null, execPath)
    }
  }
860993
function execFile(cmd, args, opts) {
    const deferred = Q.defer();
    childProcess.execFile(cmd, args, opts, function(err, stdout, stderr) {
        if (err) {
            console.error("Error executing " + cmd + " " + args.join(" "));
            console.error(stdout + stderr);
            err.stdout = stdout;
            err.stderr = stderr;
            deferred.reject(err);
        } else {
            deferred.resolve(stdout);
        }
    });
    return deferred.promise;
}
1142700
def run_command(args, asynchronous=False):
    """"""
    logging.info("Executing %s command %s.",
                 asynchronous and 'asynchronous' or 'synchronous', args)

    process = subprocess.Popen(args,
                               shell=True,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.STDOUT)

    try:
        timeout = asynchronous and 1 or None
        output = process.communicate(timeout=timeout)[0].decode('utf8')
    except subprocess.TimeoutExpired:
        pass

    if asynchronous:
        return PopenOutput(None, 'Asynchronous call.')
    else:
        return PopenOutput(process.returncode, output)
1370172
def _execute(self, worker):
        
        self._assert_status_is(TaskStatus.RUNNING)
        operation = worker.look_up(self.operation)
        operation.invoke(self, [], worker=worker)
216775
public static ExecutorService startWithExecutorService(
            ExecutorService executorService, String message,
            Runnable runnable) {
        runAsync(() -> {
            JMLog.info(log, "startWithExecutorService", message);
            runnable.run();
        }, executorService);
        return executorService;
    }
13998
public void start() {
    if (isActive) {
      return;
    }

    log.info("Starting up the default async job executor [{}].", getClass().getName());
    
    if (timerJobRunnable == null) {
      timerJobRunnable = new AcquireTimerJobsRunnable(this, processEngineConfiguration.getJobManager());
    }
    
    if (resetExpiredJobsRunnable == null) {
      resetExpiredJobsRunnable = new ResetExpiredJobsRunnable(this);
    }
    
    if (!isMessageQueueMode && asyncJobsDueRunnable == null) {
      asyncJobsDueRunnable = new AcquireAsyncJobsDueRunnable(this);
    }
    
    if (!isMessageQueueMode) {
      initAsyncJobExecutionThreadPool();
      startJobAcquisitionThread();
    }
    
    startTimerAcquisitionThread();
    startResetExpiredJobsThread();

    isActive = true;

    executeTemporaryJobs();
  }
711910
@Beta
  public Future<HttpResponse> executeAsync(Executor executor) {
    FutureTask<HttpResponse> future =
        new FutureTask<HttpResponse>(
            new Callable<HttpResponse>() {

              public HttpResponse call() throws Exception {
                return execute();
              }
            });
    executor.execute(future);
    return future;
  }
246250
async function run(task, action, ...args) {
  const command = process.argv[2]
  const taskName =
    command && !command.startsWith('-') ? `${task} ${command}` : task
  const start = new Date()
  process.stdout.write(`Starting '${taskName}'...\n`)
  try {
    await action(...args)
    process.stdout.write(
      `Finished '${taskName}' after ${new Date().getTime() -
        start.getTime()}ms\n`
    )
  } catch (error) {
    process.stderr.write(`${error.stack}\n`)
  }
}
1238241
def start_polling(dispatcher, *, loop=None, skip_updates=False, reset_webhook=True,
                  on_startup=None, on_shutdown=None, timeout=20, fast=True):
    
    executor = Executor(dispatcher, skip_updates=skip_updates, loop=loop)
    _setup_callbacks(executor, on_startup, on_shutdown)

    executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, fast=fast)
755998
public void run(
      List<String> command,
      @Nullable Path workingDirectory,
      @Nullable Map<String, String> environment,
      ConsoleListener consoleListener)
      throws InterruptedException, CommandExitException, CommandExecutionException {
    ProcessExecutor processExecutor = processExecutorFactory.newProcessExecutor();
    try {
      int exitCode =
          processExecutor.run(
              command,
              workingDirectory,
              environment,
              streamHandlerFactory.newHandler(consoleListener),
              streamHandlerFactory.newHandler(consoleListener));
      if (exitCode != 0) {
        throw new CommandExitException(exitCode);
      }
    } catch (IOException ex) {
      throw new CommandExecutionException(ex);
    }
  }
733242
def worker_exec(self, **kwargs):
        """"""
        self.feed(**kwargs)
        self.logger.info('thread {} exit'.format(current_thread().name))
764473
public void runAsync(int startSuccessTimeout) throws MojoExecutionException {
    runMojo
        .getLog()
        .info("Waiting " + startSuccessTimeout + " seconds for the Dev App Server to start.");
    try {
      runMojo
          .getAppEngineFactory()
          .devServerRunAsync(startSuccessTimeout)
          .run(configBuilder.buildRunConfiguration(processServices(), processProjectId()));
    } catch (AppEngineException ex) {
      throw new RuntimeException(ex);
    }
    runMojo.getLog().info("Dev App Server started.");
    runMojo.getLog().info("Use the 'mvn appengine:stop' command to stop the server.");
  }
610592
def main(event_loop=None):
    
    context, credentials = get_context_from_cmdln(sys.argv[1:])
    log.info("Scriptworker starting up at {} UTC".format(arrow.utcnow().format()))
    cleanup(context)
    context.event_loop = event_loop or asyncio.get_event_loop()

    done = False

    async def _handle_sigterm():
        log.info("SIGTERM received; shutting down")
        nonlocal done
        done = True
        if context.running_tasks is not None:
            await context.running_tasks.cancel()

    context.event_loop.add_signal_handler(signal.SIGTERM, lambda: asyncio.ensure_future(_handle_sigterm()))

    while not done:
        try:
            context.event_loop.run_until_complete(async_main(context, credentials))
        except Exception:
            log.critical("Fatal exception", exc_info=1)
            raise
1321938
def run_process(self, analysis, action_name, message='__nomessagetoken__'):
        

        if action_name == 'connect':
            analysis.on_connect(self.executable, self.zmq_publish)

        while not analysis.zmq_handshake:
            yield tornado.gen.sleep(0.1)

        log.debug('sending action {}'.format(action_name))
        analysis.zmq_send({'signal': action_name, 'load': message})

        if action_name == 'disconnected':
            # Give kernel time to process disconnected message.
            yield tornado.gen.sleep(0.1)
            analysis.on_disconnected()
191578
@VisibleForTesting
  protected void startExecutor(final int container, Set<PackingPlan.InstancePlan> instances) {
    LOG.info("Starting a new executor for container: " + container);

    // create a process with the executor command and topology working directory
    final Process containerExecutor = startExecutorProcess(container, instances);

    // associate the process and its container id
    processToContainer.put(containerExecutor, container);
    LOG.info("Started the executor for container: " + container);

    // add the container for monitoring
    startExecutorMonitor(container, containerExecutor, instances);
  }