Provides the boilerplate code for running and waiting on a Runnable.
433469
public static void runAndWait(final Runnable r) {
        try {
            if (r != null) {
                final Thread thread = new Thread(r);
                thread.start();
                thread.join();
            }
        } catch (final Exception ex) {
            LOG.debug("Thread has been interrupted and cannot be joined", ex);
        }
    }
929911
def runAndWait(self):
        
        if self._inLoop:
            raise RuntimeError('run loop already started')
        self._inLoop = True
        self._driverLoop = True
        self.proxy.runAndWait()
595245
public static void asyncExecute(Runnable runnable) {
		if (runnable != null) {
			try {
				Para.getExecutorService().execute(runnable);
			} catch (RejectedExecutionException ex) {
				logger.warn(ex.getMessage());
				try {
					runnable.run();
				} catch (Exception e) {
					logger.error(null, e);
				}
			}
		}
	}
371900
void enqueue(Runnable runnable, boolean flush) {
    queue.add(new RunnableCommand(runnable));
    if (flush) {
      scheduleFlush();
    }
  }
972752
def _get_runner(classpath, main, jvm_options, args, executor,
               cwd, distribution,
               create_synthetic_jar, synthetic_jar_dir):
  """"""

  executor = executor or SubprocessExecutor(distribution)

  safe_cp = classpath
  if create_synthetic_jar:
    safe_cp = safe_classpath(classpath, synthetic_jar_dir)
    logger.debug('Bundling classpath {} into {}'.format(':'.join(classpath), safe_cp))

  return executor.runner(safe_cp, main, args=args, jvm_options=jvm_options, cwd=cwd)
1213994
def wait_until_running(self, callback=None):
        """"""
        status = self.machine.scheduler.wait_until_running(
                self.job, self.worker_config.time_out)

        if status.running:
            self.online = True
            if callback:
                callback(self)
        else:
            raise TimeoutError("Timeout while waiting for worker to run: " +
                               self.worker_config.name)
254523
def run_in_greenlet(callable):
    
    @wraps(callable)
    async def _(*args, **kwargs):
        green = greenlet(callable)
        # switch to the new greenlet
        result = green.switch(*args, **kwargs)
        # back to the parent
        while isawaitable(result):
            # keep on switching back to the greenlet if we get an awaitable
            try:
                result = green.switch((await result))
            except Exception:
                exc_info = sys.exc_info()
                result = green.throw(*exc_info)

        return green.switch(result)

    return _
384264
public final void waitForFullService() {
        if (!m_state.isInitialized()) {
            throw new RuntimeException("Service has not been initialized");
        }
        synchronized (m_stateChangeLock) {
            // Loop until state >= RUNNING
            while (!m_state.isRunning()) {
                try {
                    m_stateChangeLock.wait();
                } catch (InterruptedException e) {
                }
            }
            if (m_state.isStopping()) {
                throw new RuntimeException("Service " + this.getClass().getSimpleName() +
                                           " failed before reaching running state");
            }
        }
    }
422854
public void run() {
        Runnable r = null;
        while (true) {
            // Try to drain the maximum capacity of thread-local items, checking
            // whether any were available
            if (workQueue.drainTo(internalQueue, threadLocalItems) == 0) {
                // block until a work item is available
                try {
                    internalQueue.offer(workQueue.take());
                } catch (InterruptedException ie) {
                    throw new Error(ie);
                }
            }
            // Execute all of the thread-local items
            while ((r = internalQueue.poll()) != null)
                r.run();
        }
    }
1164803
def build_on_start(self, runnable, regime, on_start):
        

        on_start_code = []

        for action in on_start.actions:
            code = self.build_action(runnable, regime, action)
            for line in code:
                on_start_code += [line]

        return on_start_code
1368127
async def awaitable_runner(runner: BaseRunner):
    """"""
    runner_thread = CapturingThread(target=runner.run)
    runner_thread.start()
    delay = 0.0
    while not runner_thread.join(timeout=0):
        await asyncio.sleep(delay)
        delay = min(delay + 0.1, 1.0)
637050
def wait_for_next_completion(self, runtime_context):
        # type: (RuntimeContext) -> None
        
        if runtime_context.workflow_eval_lock is not None:
            runtime_context.workflow_eval_lock.wait()
        if self.exceptions:
            raise self.exceptions[0]
604493
def run(self, *args, **kwargs):
        
        if self._source is not None:
            return self._source.run(*args, **kwargs)
        else:
            self.queue(*args, **kwargs)
            return self.wait()
16075
def wait(self):
        
        running = True
        while running and self.messages_pending():
            running = self.do_work()
        return running
528031
@Override
    public void run() {
        try {
            if (this.isDone()) {
                return;
            }
            ExpeditedFutureTask<V> futureTask = new ExpeditedFutureTask<V>(this.m_callable);
            this.m_defaultFuture = futureTask;
            this.m_executor.execute(futureTask);
            this.m_scheduledExecutorQueue.remove(this);
        } catch (Exception e) {
            this.m_pendingException = new RuntimeException(e);
            return;
        } finally {
            // Let blocked ScheduleFuture methods thru now.
            this.m_coordinationLatch.countDown();
        }
    }
185012
def run(self, *args):
        """"""

        params = self.parser.parse_args(args)
        sources = params.source
        code = self.autocomplete(sources)

        return code
60441
def runAndWait(self):
        '''
        
        '''
        self._push(self._engine.endLoop, tuple())
        self._driver.startLoop()